Skip to content

Admin SDK should support publishing topics to rooms #2303

Description

@uriva

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions