Start

Introduction

Typed events, presence and durable AI streams over one connection per channel.

Pulse gives an app three realtime primitives behind one API: typed events, presence, and durable AI streams of plain text or AG-UI events. Each is one line in the browser, and each runs over the same connection to a channel.

server.ts ยท page.tsx
tsx
// On your server: sign a token, publish an eventconst token = await rt.token({ user: { id, name }, channels: ["orders:*"] })await rt.publish("orders:42", "order.status", { status: "shipped" })
// In the browser: the latest status, liveconst status = useEvent("orders:42", "order.status")

How it fits together

  • Your server holds a secret key. It signs short-lived tokens for the browser and publishes events.
  • A browser connects to a channel with its token. A channel is just a name, like orders:42 or chat:9f2c: it exists once something uses it, with nothing to create or configure.
  • Every event on a channel is stored before anyone receives it, so a client that drops gets exactly what it missed when it comes back.

The three primitives

PrimitiveWhat it's for
EventsTyped messages your server or the browser publishes: order updates, notifications, chat. Ordered, stored and replayed.
PresenceWho's on a channel and their live state: cursors, selections, typing. The newest state wins.
AI streamsA model's output as plain text, or an agent's run as AG-UI events with tool calls and approvals, token by token, with Stop. A refresh replays it, then follows live.

Start with the Quickstart, then read the page for the primitive you need: Events, Presence or AI streams.

Packages

PackageUse it for
@anishroy/pulse/serverYour server: tokens, publishing, reading history, writing AI streams.
@anishroy/pulse/reactHooks: useEvent, useChannel, usePresence, useTyping, useStream.
@anishroy/pulse/uiOptional components: live cursors, presence avatars, a typing indicator, chat messages with approval cards.
@anishroy/pulse/clientThe browser client without React (3.2 KB minified and gzipped).
@anishroy/pulse/ai-sdkPulseChatTransport: answers for the AI SDK's useChat that survive a refresh.

With a coding agent

Point your agent at https://pulse.anishroy.com/agents.md: how to add Pulse to an app, and the rules that keep it right. It is an Agent Skill too, so you can keep it with your agent's skills:

Terminal
bash
# Claude Code reads skills from .claude/skills; other agents have their own foldermkdir -p .claude/skills/pulsecurl -o .claude/skills/pulse/SKILL.md https://pulse.anishroy.com/agents.md

Every docs page is also Markdown: add .md to its URL, or start from /llms.txt, the index, or /llms-full.txt, every page in one file.

Limits

  • 1 MB per message
  • 5,000 connections per channel
  • 1,000 presence members per channel
  • 10 / s presence updates per connection
  • 7 days of history (24 hours by default)