{"id":13760575,"url":"https://github.com/noahlh/celestite","last_synced_at":"2025-08-09T23:44:55.026Z","repository":{"id":42931444,"uuid":"141370338","full_name":"noahlh/celestite","owner":"noahlh","description":"Beautifully reactive, server-side rendered Svelte apps w/ a Crystal backend","archived":false,"fork":false,"pushed_at":"2024-05-28T17:41:07.000Z","size":2936,"stargazers_count":232,"open_issues_count":26,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-02T14:05:41.163Z","etag":null,"topics":["amber","amber-framework","crystal","framework","isomorphic","sapper","sapperjs","ssr","svelte","universal","web"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noahlh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-18T02:29:02.000Z","updated_at":"2025-01-21T20:35:37.000Z","dependencies_parsed_at":"2024-08-03T13:16:26.153Z","dependency_job_id":null,"html_url":"https://github.com/noahlh/celestite","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":"0.31034482758620685","last_synced_commit":"ed08825c09815b1487a30cbd6039013831458393"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahlh%2Fcelestite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahlh%2Fcelestite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahlh%2Fcelestite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahlh%2Fcelestite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noahlh","download_url":"https://codeload.github.com/noahlh/celestite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065281,"owners_count":21041872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amber","amber-framework","crystal","framework","isomorphic","sapper","sapperjs","ssr","svelte","universal","web"],"created_at":"2024-08-03T13:01:13.332Z","updated_at":"2025-04-09T16:19:47.420Z","avatar_url":"https://github.com/noahlh.png","language":"Crystal","funding_links":[],"categories":["Crystal"],"sub_categories":[],"readme":"![](https://github.com/noahlh/celestite/workflows/crystal%20spec/badge.svg?branch=master)\n\n# celestite\n\n\u003cimg src=\"https://crystal-lang.org/assets/media/crystal_icon.svg?sanitize=1\" height=21\u003e Crystal + \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/1/1b/Svelte_Logo.svg\" height=16\u003e Svelte = :zap:\n\nCelestite allows you to use the full power of [Svelte](https://svelte.dev) reactive components in your [Crystal](https://crystal-lang.org) web apps. It's a drop-in replacement for your view layer -- no more need for intermediate `.ecr` templates. With celestite, you write your backend server code in Crystal, your frontend client code in JavaScript \u0026 HTML, and everything works together seamlessly...and fast.\n\n## Introduction\n\n[Read the full introductory blog post here.](https://nlh.me/projects/celestite)\n\n### Requirements\n\n- Crystal 0.35.1+\n- Yarn 1.12+\n- Node 10+\n\nThe render server was built using node 10.15.3 (in particular it uses the WHATWG URL Standard, which was added in Node 7+.) It doesn't need to do this, strictly-speaking, and if there's a compelling reason to support earlier versions of Node I'm happy to make this change.)\n\n## Installation\n\n#### THIS IS PREVIEW / EARLY ALPHA SOFTWARE\n\n**This is not much more than a proof-of-concept at the moment, but it does work! Standard warnings apply - it will likely break/crash in spectacular and ill-timed glory, so don't poke it, feed it past midnight, or use it for anything mission-critical (yet).**\n\nCelestite has been developed / tested with the [Amber](https://amberframework.org) web framework, but designed to work standalone as well. There's also no reason it won't work with [Lucky](https://luckyframework.org/), [Kemal](http://kemalcr.com/), [Athena](https://athenaframework.org), etc. (but no work integrating with those has been done yet.) The steps below assume you'll be working with Amber.\n\n### 1. Add celestite to your application's `shard.yml` and run `shards install`\n\n```yaml\ndependencies:\n  celestite:\n    github: noahlh/celestite\n    version: ~\u003e 0.1.3\n```\n\n### 2. Include the helper `Celestite::Adapter::Amber` in your `application_controller.cr`\n\nThis adds the `celestite_render` macro.\n\n```crystal\n  # application_controller.cr\n\n  require \"jasper_helpers\"\n\n  class ApplicationController \u003c Amber::Controller::Base\n    include JasperHelpers\n+   include Celestite::Adapter::Amber\n  end\n```\n\n### 3. Add `celestite_amber_init.cr` to `/config/initializers`\n\n[An example](/config/celestite_amber_init.example.cr) is provided. You can name this file whatever you want, just so long as it gets called upon initialization.\n\n### 4. Add an `_error.svelte` to your views directory\n\nThis is required for the time being because Sapper expects it. If it's missing, your app will still work, but there will be some weirdness with CSS rendering (trust me - this cost me an evening ;)\n\n```html\n\u003cscript\u003e\n  export let status;\n  export let error;\n\u003c/script\u003e\n\n\u003ch1\u003e{status}\u003c/h1\u003e\n\u003cp\u003e{error.message}\u003c/p\u003e\n```\n\n### 4. Add a static route for your build_dir to Amber's static pipeline\n\nThis is because of a slight hitch with how Svelte works behind the scenes (via [Sapper](https://sapper.svelte.dev)), but essentially: the client needs to be able to access the relevant JS files in /client, yet Sapper needs complete control over that directory (it wipes it with each new build). So we simultaneously give it its own directory and also make it available via the root path.\n\n```crystal\n # routes.cr\n\n pipeline :static do\n   plug Amber::Pipe::Error.new\n   plug Amber::Pipe::Static.new(\"./public\")\n+  plug Amber::Pipe::Static.new(\"./public/celestite\")\n end\n```\n\n### And finally...\n\n### 5. Add your `.svelte` files and start building!\n\nA note on naming: make sure you follow Sapper's [file naming rules](https://sapper.svelte.dev/docs#File_naming_rules). Hint: the root component should be named `index.svelte` (all lowercase).\n\n## Usage details\n\n**`celestite_render`**`(context : Celestite::Context = nil, path : String? = nil, template : String? = nil)`\n\nPerforms the render. This is to be called where you'd normally call `render` in your controllers. It doesn't need any parameters by default (it automatically extracts the path of the method calling it based on your Amber routes), but you may use the following optional parameters:\n\n- `context : Celestite::Context`\n\n  Celestite uses a Hash literal called `Celestite::Context`. Any variables you'd like available in your components go in here, using a Symbol key of the desired name.\n\n  So if you want to access `example_crystal_data` in your vue component, assign the relevant value to `my_context[:example_crystal_data]`. See example below for details\n\n  This is acheived using Sapper's [session-seeding](https://sapper.svelte.dev/docs#Seeding_session_data) mechanism.\n\n- `path : String?`\n\n  If you need to manually specify which path you're rending (i.e. you're not in Amber), you can pass in a string parameter. In Amber this will be assigned a default value equal to the current Amber route the controller method is handling.\n\n- `template : String?`\n\n  **(Not implemented yet)** Which layout/template you'd like to render the component in. Will use a default template specified in the init file if none specified on render.\n\n## Example controller\n\n```crystal\n# home_controller.cr\n\nclass HomeController \u003c ApplicationController\n  def index\n    data = 1 + 1\n    context = Celestite::Context{:data =\u003e data}\n    celestite_render(context)\n  end\nend\n```\n\n## Server vs client rendering (Node/JavaScript)\n\nYour `.svelte` components will automatically be rendered server-side before being sent to the client. This is usually seamless, but you'll need to be aware of any code (or libraries) that rely on browser-specific APIs (such as `document` or `window`). This will throw an error when the components are rendered in the context of node (vs the browser).\n\nTo get around this, you can import Sapper's `onMount()` function. Any function wrapped in `onMount()` will be rendered in the (browser) client only.\n\n[You can read more about server-side rendering considerations here.](https://sapper.svelte.dev/docs#Server-side_rendering)\n\n## Project status\n\nMy goal/philosophy is to release early, release often, and get as much user feedback as early in the process as possible, so even though the perfectionist in me would like to spend another 6 years improving this, by then it'll be 2024 and who knows we might all be living underwater. No time like the present.\n\n## Roadmap\n\nShort-term goals:\n\n- [x] Release the embarrassing 0.1.0 version (originally supported Vue)\n- [x] Fix reloading issues (not everything restarts properly)\n- [x] Figure out Hot Module Reloading (HMR)\n- [x] Add support for Svelte (released in 0.1.2)\n- [ ] Get usage --\u003e expose bugs\n- [ ] Get example / demo project live\n- [ ] Switch over to SveltKit when it's live\n\nLonger-term goals:\n\n- Performance \u0026 code cleanliness improvements\n- Remove need for a separate node process / http (evaluate JS in crystal?)\n\n## Contributions / critique wanted!\n\nThis has been a solo project of mine and I would love nothing more than to get feedback on the code / improvements / contributions. I've found by far the best way to learn and level-up development skills is to have others review code that you've wrestled with.\n\nThat is to say, don't hold back. Report things that are broken, help improve some of the code, or even just fix some typos. Everyone (at all skill levels) is welcome.\n\n1. Fork it (\u003chttps://github.com/noahlh/celestite/fork\u003e)\n2. Create your feature/bugfix branch (`git checkout -b omg-this-fixed-so-many-bugs`)\n3. Make magic (and don't forget to write tests!)\n4. Commit your changes (`git commit -am 'Made a fix!'`)\n5. Push to the branch (`git push origin omg-this-fixed-so-many-bugs`)\n6. Create a new Pull Request\n7. ::party::\n\n## Contributors\n\n- Noah Lehmann-Haupt (nlh@nlh.me / [noahlh](https://github.com/noahlh)) - creator, maintainer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahlh%2Fcelestite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoahlh%2Fcelestite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahlh%2Fcelestite/lists"}