What you can subscribe to
Each subscription delivers the complete run object with automatic updates whenever the run changes.
What updates you receive
- Status changes —
QUEUED→EXECUTING→COMPLETED(orFAILED,CANCELED, etc.) - Metadata updates — Custom progress data written by your task using
metadata.set() - Tag changes — When tags are added or removed from the run
- Realtime streams — Binary or JSON chunks appended with
streams.pipe()orstreams.append()inside your task
Streaming AI output
Trigger.dev Realtime is designed to work seamlessly with LLM output streaming. Your task pipes tokens directly to the Realtime API, and subscribers receive them as they arrive.In your task
Usestreams.pipe() to forward an async iterable or ReadableStream to the Realtime API:
streams.pipe() returns the original stream so you can consume it locally in the task while
simultaneously forwarding chunks to subscribers. Call waitUntilComplete() before returning
to guarantee all chunks have been flushed.Multiple named streams
You can maintain multiple independent streams in a single run by passing a key:Writing chunks manually
If you want to push individual values rather than pipe an existing stream, usestreams.append():
Authentication
All Realtime subscriptions require a Public Access Token. These are short-lived JWT tokens that are safe to expose to the browser. There are two ways to obtain one:- From the run handle — When you trigger a task, the returned handle includes a
publicAccessTokenthat is already scoped to that run. - Generated server-side — Use
auth.createPublicToken()to create tokens scoped to specific runs, tags, or batches.
accessToken option.
Subscribing from the backend
You can subscribe to run updates from Node.js, other tasks, or serverless functions usingruns.subscribeToRun():
Next steps
React hooks
Use
useRealtimeRun and useRealtimeRunWithStreams in your React components.Wait for token
Pause a run and resume it from the frontend or an external webhook.
Building with AI
Patterns for LLM chains, agent loops, and human-in-the-loop workflows.
MCP Server
Let your AI assistant interact with your Trigger.dev project.