Skip to content

dweldon/datastar-bun-hono-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

datastar-bun-hono-example

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.

Commands

bun install
bun dev

Heartbeat example

Pass 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 }
  );
});

LLM Docs

If you are looking for a companion set of distilled LLM reference docs for Datastar, check out these.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors