Realtime
Live updates without reloading: chat, presence, collaborative editing, live dashboards.
In stackly.json and the CLI it is realtime. Its use, live or draft, is counted as realtime connections; see Live app prices.
realtime · optional · needs backend · Durable Objects (WebSocket rooms) · binding APP_REALTIME
Live updates without reloading: chat, presence, collaborative editing, live dashboards.
Turn it on
"features": ["backend", "realtime"]
Use it
Let a visitor join a room from a GET route, after checking who they are and that they may join:
// src/routes/api/rooms.$room.ts
import { createFileRoute } from "@tanstack/react-router";
import { connectRoom } from "#/lib/realtime.server";
export const Route = createFileRoute("/api/rooms/$room")({
server: {
handlers: {
GET: async ({ request, params }) => {
// authenticate and authorize here
return connectRoom(request, params.room);
},
},
},
});
Broadcast from server code after an action succeeds:
import { publishToRoom } from "#/lib/realtime.server";
const sent = await publishToRoom("board-42", JSON.stringify({ type: "card.moved", id }));
if (!sent.ok) console.error("broadcast failed", sent.status);
- Return
connectRoom's response as it is, so the WebSocket upgrade survives. - The browser connects to a same-origin
wss://…/api/rooms/<room>. Browser writes go through an authenticated HTTP call; the server broadcasts the result. - Re-fetch the data on reconnect: missed events are not replayed.
Limits
Room names: 1–80 letters, digits, _ or -. Messages up to 8,192 bytes. Per room 32 sockets and 30 broadcasts a
minute; per app environment 128 sockets and 120 broadcasts a minute.
Locally
stackly dev runs rooms locally. Draft, live and local rooms are separate.