Skip to main content
Trigger.dev Realtime lets you subscribe to background runs from your frontend or backend and receive live updates as they execute. It is built on top of Server-Sent Events (SSE) and works with any framework that supports streaming responses.

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 (or FAILED, 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() or streams.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

Use streams.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, use streams.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:
  1. From the run handle — When you trigger a task, the returned handle includes a publicAccessToken that is already scoped to that run.
  2. Generated server-side — Use auth.createPublicToken() to create tokens scoped to specific runs, tags, or batches.
Pass the token to your React hooks or backend subscription via the accessToken option.

Subscribing from the backend

You can subscribe to run updates from Node.js, other tasks, or serverless functions using runs.subscribeToRun():
To subscribe to all runs with a specific tag:

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.