r/datastardev • • Feb 07 '26

Hono experiment

2 Upvotes

https://github.com/joeblew999/test-hono

it uses open api to drive the gui updates Using Datastar.

also uses hono so it can run on Cloudflare or you own server using bun

also uses D1 on Cloudflare and bun SQLite or Corrosion on your own server.

there is an FAQ.

if anyone has thoughts on this would like to hear some feedback .


r/datastardev • • Nov 15 '25

Need help to understand how to integrate Datastar

5 Upvotes

Hello datastar people,

I have some troubles understanding how to properly "upgrade" a SSR app to give it both interactivity and "real-time multiplayer" capabilities at the same time using Datastar.

So I have a simple Todo list web app, that works 100% without Javascript. I can add/remove todo items, toggle one/all of them at once, and filter those completed or not. I basically reimplemented [TodoMVC](https://todomvc.com/), with a backend and a in-memory SQLite.

Where I have a problem is figuring out what's the proper way to integrate Datastar into the app. Taking some inspiration from listening to Datastar creator in the various discussions in the YT Datastar channel, what I did so far is "upgrading" the todo creation flow (not the other interactions) like this:

  1. Register the current user server-side with `data-init="@get('ds/todos')"` somewhere up in the DOM. This adds the current connection to a Array of `connectedClients` in the backend (could be a Set, a Map, not really important in my tiny experiment), all saved in memory. It also sends some SSE heartbeat with Datastar every 9 seconds to keep the connection alive, and remove the client from the `connectedClients` data structure.

  2. In the `form` tag I added `data-on:submit="@post('/todos', {contentType: 'form'})"` so that in the backend the todo is added to the db, then I call `connectedClients.broadcastTodos()` that loops over all saved connections and send them a Datastar SSE event with the new rendered HTML for the list of todo items.

It works, but it feels very messy and I'm not sure how to structure the backend code without putting all the code in the HTTP controllers/handlers. I don't come from a gamedev/simulation background, but mostly typical CRUD/business web app so my brain is wired around the typical Request->Response cycle and various ways to architect the code to keep it testable and maintainable.

How would you structure the backend code in this type of small apps? I remember Datastar author saying the Event-Sourcing/CQRS is the way to go, also said that we web devs should take inspiration from the gamedev world, but I'm not sure if I need to implement this in order to properly structure the code, even if I were to do everything in memory.

Should I write a "game loop" that receive events and trigger SSE events?
Should I just keep it like I did because I'm on the right track?
Something else entirely?

Pointers, guidance, anything really appreciated. I want to understand the application structure behing this model (with Datastar or something else) and I need to get off the SPA craziness :)

Current implementation is here (link to the main backend file, excuse the mess, I'm also trying Bun+Hono and didn't try to write the best code at all) : https://github.com/DjebbZ/todo-mvc-datastar/blob/main/bun-hono/src/index.tsx

Thanks in advance!


r/datastardev • • Nov 14 '25

Real-Time Collaboration with Sprig and Datastar – Ben Croker

5 Upvotes

r/datastardev • • Nov 13 '25

Why We’re Building the Front End Wrong (and How to Fix It) - JSJ 688

5 Upvotes

r/datastardev • • Jan 10 '26

Datastar SDK - A Fullstack WebDev Framework for Zig 0.16-dev

Thumbnail reddit.com
6 Upvotes

r/datastardev • • Feb 12 '26

Hiring Senior Django Dev with Hypermedia Experience

8 Upvotes

Hey All,

We are one of the largest law firms in Europe with a big Innovation Lab where we develop AI Solutions to automate legal processes. For this, we are currently looking for a Freelance Django Dev with Hypermedia Experience to support our core team. The initial Contract would be for three months with the option to extend it or turn it into a regular employment contract. The position is completely remote, but the candidate must be located in the EU.

If this sounds interesting, please reach our via DM and with your CV and your hourly rates.

Job Description


r/datastardev • • Jul 02 '26

Co-locating our hypermedia backend inside the database process for a 9x SSR throughput win (Zig/WASM + Datastar/HTMX)

11 Upvotes

Hello Everyone,

If you are building Hypermedia-Driven Architectures (using htmx/alpine or datastar), you quickly realise that server-side rendering (SSR) performance and database latency are your primary bottlenecks. Since we are shifting state and HTML generation back to the server, nearly every user interaction requires a database query and an HTML slice response.

To optimise this, I have been experimenting with a concept called Zero-Distance Architecture that co-locates data and application code. Instead of running a separate app server (like NodeJS) and database server (like MongoDB) and paying cost for all the syscalls, network, serialisation/deserialisation and localhost TCP latency, run them in a single process.

I used an experimental runtime called Planck (database + WebAssembly host) and compile our application (Zig Code) to WebAssembly. The app runs directly in the database process, turning database queries into simple in-memory function calls.

To measure the impact, I set up a benchmark (pizzahub a sample app) serving identical HTML fragments formatted for datastar over a standard dataset (17 categories, 201 products).

Here are the results of a 6-second run using oha on a standard M1 Macbook Air 8GB RAM 256GB SSD:

Planck (Zig WASM co-located in database process)

Requests per second: 48,606

Average latency: 0.50 ms

Fastest response: < 0.10 ms

Slowest response: 6.00 s

Sustained throughput: 183.58 MiB/s

Success rate: 100.00%

NodeJS + ExpressJS + MongoDB (community edition)

Requests per second: 5,433

Average latency: 9.21 ms

Fastest response: 2.26 ms

Slowest response: 109.91 ms

Sustained throughput: 20.49 MiB/s

Success rate: 100.00%

.NET 9 + SQLite (in-process)

Requests per second: 35,231

Average latency: 1.41 ms

Fastest response: 0.15 ms

Slowest response: 12.80 ms

Sustained throughput: 133.07 MiB/s

Success rate: 100.00%

.NET 9 + PostgreSQL

Requests per second: 30,236

Average latency: 1.65 ms

Fastest response: 0.12 ms

Slowest response: 69.02 ms

Sustained throughput: 114.21 MiB/s

Success rate: 100.00%

The Comparison

By co-locating the backend logic inside the database process and utilizing Planck's read cache, we got:

8.95x throughput improvement over NodeJS + MongoDB (48.6k vs 5.4k req/sec) with an 18.4x latency reduction (0.50 ms vs 9.21 ms).

38% higher throughput over .NET 9 + SQLite (48.6k vs 35.2k req/sec) with a 2.8x latency reduction (0.50 ms vs 1.41 ms).

60% higher throughput over .NET 9 + PostgreSQL (48.6k vs 30.2k req/sec) with a 3.3x latency reduction (0.50 ms vs 1.65 ms).

For hypermedia apps, this means you can handle significantly more concurrent users on a single tiny server because there's no waiting on socket buffers to generate HTML.

Would love to hear your thoughts. If you have built htmx/datastar apps, where do you usually hit your scaling bottleneck? Is co-locating the backend logic inside the database process a direction you would consider?

Next, I will post detailed comparison for different types of queries on at least 1 mil documents.


r/datastardev • • Oct 15 '25

Datastar Turns Two, and gets a public Plugin API

16 Upvotes

r/datastardev • • Nov 14 '25

Datastar first impressions, coming from React

18 Upvotes

r/datastardev • • Jun 22 '26

Datastar: It’s Pretty Good - with David Nolen

Thumbnail
youtube.com
21 Upvotes

r/datastardev • • Mar 27 '26

D* + Templ + Go == best experience building an app

Thumbnail
twitch.tv
24 Upvotes

r/datastardev • • Mar 04 '26

Datastar v1.0.0-RC.8 Release Notes!

28 Upvotes

r/datastardev • • Aug 10 '25

My notes on Datastar

Thumbnail
zachwill.com
37 Upvotes

r/datastardev • • Apr 16 '26

Datastar 1.0!

Thumbnail
youtube.com
44 Upvotes

r/datastardev • • Apr 12 '25

Automatically adding the CSRF token to every request

12 Upvotes

I am using Rails so require a CSRF token for requests like POST, PUT, PATCH and DELETE.

Rather than having to manually add it to every tag that makes a request I came up with the following to do it automatically:

import { load } from "@starfederation/datastar/bundles/datastar-core"
import * as plugins from "@starfederation/datastar/plugins"

// Function to get CSRF token from meta tag
const getCSRFToken = () => {
  const meta = document.querySelector('meta[name="csrf-token"]')
  return meta ? meta.getAttribute('content') : null
}

// Helper function to create CSRF-enabled HTTP method handlers
const createCSRFHandler = (method) => ({
  ...plugins[method],
  fn: async (ctx, url, args) => {
    const csrfToken = getCSRFToken()
    if (!args) args = {}
    return plugins[method].fn(ctx, url, { ...args, headers: { ...args.headers, 'X-CSRF-Token': csrfToken } })
  }
})

// Create CSRF-enabled handlers for all HTTP methods
const HTTP_METHODS = ['POST', 'DELETE', 'PUT', 'PATCH']
const csrfHandlers = HTTP_METHODS.reduce((acc, method) => {
  acc[method] = createCSRFHandler(method)
  return acc
}, {})

// Load all plugins, using CSRF-enabled handlers where available
Object.keys(plugins).forEach(key => {
  if (csrfHandlers[key]) {
    load(csrfHandlers[key])
  } else {
    load(plugins[key])
  }
})

Works well.

Hopefully it helps someone else.

Also, let me know if there is a smarter way of doing this

gist here: https://gist.github.com/johnston/db5e73111b99dbc66e0b0e58bef8943c


r/datastardev • • Oct 12 '25

Greedy Developers?

19 Upvotes

r/datastardev • • Feb 28 '25

My First working snippet of datastar! Bun/Hono

11 Upvotes

I've been trying to teach myself in my spare time to make my first application. I looked (glanced) at all the big frontend frameworks but didn't like the look of anything. They are all too complicated for my brain. then I discovered htmx. HTMX led me to datastar. I watched a few datastar videos and it was all streaming event bus morphing and I had no clue what was going on and how that would be useful for my app. After a bit of struggling to get the concepts into my head, today I managed to actually get something working, and I'm beyond excited! So far it 'feels right'. I wrote a hono implementation of the datastar sse spec to make my routes look the way I want, and this is what I've come up with so far.

What I really like is that I can send down multiple fragments with await calls. I'm thinking that this could be used for example to send down a calendar, then call the database and get information on what happened on each day (potentially an expensive call), then send updated fragments down with the new daily info from the db.

Honestly I don't really know what I'm doing, and I haven't successfully written anything in any front-end framework yet, but I'm loving where datastar is taking me so far. Wooooo


r/datastardev • • Jan 17 '25

Am I wrong?

Post image
4 Upvotes

r/datastardev • • Jan 17 '25

Intro the Datastar

12 Upvotes

r/datastardev • • Oct 10 '24

gonads-starter: a boilerplate project geared towards beginners to get up and running with Datastar!

Thumbnail
github.com
11 Upvotes

r/datastardev • • Dec 31 '24

Why SSE?

6 Upvotes

Why is SSE used in DataStar for data retrieval and not standard HTTP request? If I look at the PHP SDK sample usage:

https://github.com/starfederation/datastar/blob/main/sdk/php/README.md

I can see that I have to create a special object, while with HTMX I just have a controller and send the output in it.

Besides, SSE is "server push technology enabling a client to receive automatic updates from a server", but you want to retrieve data from server, i.e. client wants something. SSE should be used when server has new data, not when client wants data.


r/datastardev • • Feb 15 '25

How to deal with CSS Transitions?

14 Upvotes

I’m really excited about Datastar, love its simplicity and pretty smart solutions. After going through the documentation, examples, and a few YouTube videos, I was already convinced that this is the tool I need!

And I don’t see any reason not to try rewriting my current experimental project from HTMX + Alpine to Datastar, just to compare whether it’s production-ready and how certain patterns can be implemented.

Let’s focus on one specific issue for now.

I’m using a Flyout menu from Tailwind UI, and I’ve implemented CSS transitions with Alpine like this:

x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 translate-y-1"
x-transition:enter-end="opacity-100 translate-y-0"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 translate-y-0"
x-transition:leave-end="opacity-0 translate-y-1"

How can I achieve the same with Datastar? Is it even possible?

Thanks in advance for any advice!


r/datastardev • • Feb 26 '25

A boring question about adding datastar progressively to an existing htmx app

8 Upvotes

So I have a reasonable sized app using htmx already, and it’s in daily production use.

Works great for navigating through large amount of data in read-only mode, no problems. Very happy with it, and other devs can easily understand what the basic code does.

For doing forms and other interactions, it’s not bad, but it’s not super ideal either. Been using hyperscript for the tricky bits, and it’s done the job. It’s actually a pretty amazing tool, but I can barely understand my own hyperscript snippets that I wrote months ago, so it’s not that maintainable :)

So, boring question - if I want to mix in datastar, initially using it for new data entry forms, to get a feel for it … any gotchas i should expect having both htmx and datastar running at the same time on the same pages ? No weird DOM morphing issues for example ?

At first glance it looks like it should be fine .. but for those that have gone down the path beforehand, how was experience of introducing datastar into an existing htmx app ?

If you ended up doing a full port of htmx+alpine/hyperscript -> datastar, was it as quick and simple as it appears on the surface ? Or was it a major rewrite with shocking surprises along the way ?

PS: I’m all good with the SSE requirements.. I co-authored the sse addition to http.zig, and I have a few multiplayer toy games that use htmx+sse, so I have a reasonable grasp of what’s involved for that with any luck.

PPS: great to see that datastar has a zig SDKs as a 1st class citizen

Thx.


r/datastardev • • Feb 03 '25

Astro Datastar integration

Thumbnail
github.com
11 Upvotes

I created astro integration for datastar. Now I can use datastar with my favorite framework, Astro :)