This is a simple example of a Datastar app using Bun and Hono.
It should correctly implement the latest spec. Note: this version has been extended to include heartbeats so bun/hono doesn't close your connection prematurely when streaming.
The file you'll want to copy is datastar-sdk.ts. There
are no dependencies apart from hono.
If you find any issues, please report them here.
bun install
bun devPass heartbeatInterval (milliseconds) to keep long-lived SSE connections open:
app.get('/updates', (c) => {
return ServerSentEventGenerator.stream(
c,
async (sse) => {
await sse.patchSignals({ signals: { status: 'processing' } });
// ...long-running work
},
{ heartbeatInterval: 15_000 }
);
});If you are looking for a companion set of distilled LLM reference docs for Datastar, check out these.