Realtime
Run updates#
Run updates provide status, metadata, and tags as a run changes. The React hook is useRealtimeRun.
import { useRealtimeRun } from "@trigger.dev/react-hooks";
const { run, error } = useRealtimeRun(runId, {
accessToken: publicAccessToken,
});Output: the component receives the current run object and re-renders as the run changes.
Streams#
Streams carry continuous data, such as AI tokens, file chunks, or progress. Define a stream in the task, then consume it with useRealtimeStream.
const stream = streams.define("answer");
await stream.pipeText(llmResponse);Output: the frontend can read data as the task produces it.
Run updates and streaming#
| Surface | Gives you | Hook |
|---|---|---|
| Run updates | Status, metadata, and tags | useRealtimeRun |
| Streaming | Continuous task-defined data | useRealtimeStream |
You can use both together: show a progress indicator with run updates and stream the response beside it.
Authentication#
Realtime hooks and functions require authentication. Use the upstream Realtime authentication guide for the current token and scope setup.