-
Notifications
You must be signed in to change notification settings - Fork 330
Description
Problem
The admin SDK (@instantdb/admin) has a Rooms class that only exposes getPresence(). There is no way to publish topics from the server side.
The core SDK (@instantdb/core) supports joinRoom().publishTopic(), but the Reactor constructor has an isClient() guard that returns early when window is not defined, making it unusable in server environments (Node.js, Deno, etc.).
Use case
We're building a chat platform where a backend endpoint needs to broadcast ephemeral UI updates (spinner progress, status changes) to connected clients in a specific room. Topics are the perfect fit for this — fire-and-forget, no persistence needed. But since the admin SDK can't publish topics, we're forced to use persistent entities + reactive queries as a workaround, which adds unnecessary DB writes.
Desired behavior
import { init } from "@instantdb/admin";
const db = init({ appId, adminToken, schema });
// Publish a topic to a room (fire-and-forget to all connected clients)
await db.rooms.publishTopic("conversation", roomId, "uiUpdate", { elementId, percentage: 0.5 });Current workaround
Using a persistent entity that clients read via useQuery, with manual cleanup of old records.