Skip to content

Instantly share code, notes, and snippets.

@cablehead
Last active March 3, 2026 14:40
Show Gist options
  • Select an option

  • Save cablehead/32a6b06dad00e939986b635402730551 to your computer and use it in GitHub Desktop.

Select an option

Save cablehead/32a6b06dad00e939986b635402730551 to your computer and use it in GitHub Desktop.

Connecting your app to Stellar for live CSS updates

Stellar is a local-first CSS generator with an interactive web editor. stellar serve serves your generated CSS and exposes a /live-refresh SSE endpoint that pushes stylesheet updates via Datastar.

stellar serve  # http://localhost:7331
$ curl localhost:7331/live-refresh
event: datastar-patch-elements
data: elements <link id="stellar-css" rel="stylesheet" href="http://localhost:7331/assets/css/stellar/...">

Add a placeholder <link> with an id and a data-init to open the SSE connection:

<head>
  <link id="stellar-css">
  <script type="module" src="https://cdn.jsdelivr.net/gh/starfederation/datastar@v1.0.0-RC.8/bundles/datastar.js"></script>
</head>
<body>
  <div data-init="@get('http://localhost:7331/live-refresh')"></div>
</body>

Datastar morphs the <link> by id, the browser fetches the stylesheet. When the config changes, Stellar pushes a new hash. No reload.

@bencroker
Copy link

Thanks for sharing!

Official instructions for setting up live refresh using a Rocket component are now also available at https://data-star.dev/pro/download#stellar-css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment