Trigger + subscribe combo hooks
Trigger a task and immediately subscribe to its run. Details in the triggering section.useRealtimeTaskTrigger- Trigger a task and subscribe to the runuseRealtimeTaskTriggerWithStreams- Trigger a task and subscribe to both run updates and streams
Subscribe hooks
useRealtimeRun
TheuseRealtimeRun hook allows you to subscribe to a run by its ID.
useRealtimeRun hook:
onComplete callback to the useRealtimeRun hook to be called when the run is completed or errored. This is useful if you want to perform some action when the run is completed, like navigating to a different page or showing a notification.
payload and output by passing skipColumns. This reduces the data sent over the wire and avoids issues such as “Large HTTP Payload” warnings in tools like Sentry.
payload, output, metadata, startedAt, delayUntil, queuedAt, expiredAt, completedAt, number, isTest, usageDurationMs, costInCents, baseCostInCents, ttl, payloadType, outputType, runTags, error. The useRealtimeRunsWithTag hook also accepts a skipColumns option in the same way.
See our run object reference for the complete schema and How it Works documentation for more technical details.
useRealtimeRunsWithTag
TheuseRealtimeRunsWithTag hook allows you to subscribe to multiple runs with a specific tag.
useRealtimeRunsWithTag hook:
useRealtimeRunsWithTag could return multiple different types of tasks, you can pass a union of all the task types to the hook:
useRealtimeBatch
TheuseRealtimeBatch hook allows you to subscribe to a batch of runs by its the batch ID.
Using metadata to show progress in your UI
All realtime hooks automatically include metadata updates. Whenever your task updates metadata usingmetadata.set(), metadata.append(), or other metadata methods, your component will re-render with the updated data.
To learn how to write tasks using metadata, see our metadata guide.
Progress monitoring
This example demonstrates how to create a progress monitor component that can be used to display the progress of a run:Reusable progress bar
This example demonstrates how to create a reusable progress bar component that can be used to display the percentage progress of a run:Status indicator with logs
This example demonstrates how to create a status indicator component that can be used to display the status of a run, and also logs that are emitted by the task:Multi-stage deployment monitor
This example demonstrates how to create a multi-stage deployment monitor component that can be used to display the progress of a deployment:Type safety
Define TypeScript interfaces for your metadata to get full type safety:Common options
accessToken & baseURL
You can pass theaccessToken option to the Realtime hooks to authenticate the subscription.
enabled
You can pass theenabled option to the Realtime hooks to enable or disable the subscription.
id
You can pass theid option to the Realtime hooks to change the ID of the subscription.
Frequently asked questions
How do I show a progress bar for a background task in React?
Usemetadata.set() inside your task to update a progress value, then read it with useRealtimeRun in your component. The hook re-renders your component on every metadata change. See Using metadata to show progress above for a complete example.
What’s the difference between run updates and streaming?
Run updates (this page) give you run state: status, metadata, and tags. They’re for progress bars, status badges, and dashboards. Streaming gives you continuous data like AI tokens or file chunks. Use run updates for “how far along is my task?” and streaming for “show me the output as it generates.”Can I subscribe to multiple runs at once?
Yes. UseuseRealtimeRunsWithTag to subscribe to all runs with a specific tag (e.g., user:123), or useRealtimeBatch for all runs in a batch. Each yields an array of run objects that update in real time.

