|
1 | 1 | --- |
2 | 2 | title: Realtime overview |
3 | 3 | sidebarTitle: Overview |
4 | | -description: Using the Trigger.dev Realtime API to trigger and/or subscribe to runs in real-time. |
| 4 | +description: "Subscribe to run state changes (status, metadata, tags) in real time from your frontend or backend." |
5 | 5 | --- |
6 | 6 |
|
7 | | -Trigger.dev Realtime allows you to trigger, subscribe to, and get real-time updates for runs. This is useful for monitoring runs, updating UIs, and building real-time dashboards. |
| 7 | +**Realtime subscriptions let you watch run state as it changes: status transitions, metadata updates, and tag changes.** You get the full [run object](/realtime/run-object) pushed to your code whenever something changes. No polling. |
8 | 8 |
|
9 | | -You can subscribe to real-time updates for different scopes of runs: |
| 9 | +For streaming continuous data from tasks (AI completions, progress chunks, file data), see [Streams](/tasks/streams). Streams and Realtime work together but solve different problems. |
10 | 10 |
|
11 | | -- **Specific runs** - Monitor individual run progress by run ID |
12 | | -- **Runs with specific tags** - Track all runs that have certain [tags](/tags) (e.g., all runs tagged with `user:123`) |
13 | | -- **Batch runs** - All runs within a specific batch |
14 | | -- **Trigger + subscribe combos** - Trigger a task and immediately subscribe to its run (frontend only) |
| 11 | +## How is Realtime different from Streams? |
15 | 12 |
|
16 | | -Once subscribed, you'll receive the complete [run object](/realtime/run-object) with automatic real-time updates whenever the [run changes](/realtime/how-it-works#run-changes), including: |
| 13 | +| | Realtime subscriptions | Streams | |
| 14 | +|---|---|---| |
| 15 | +| **What it sends** | Run state (status, metadata, tags) | Arbitrary data you define (AI tokens, progress, files) | |
| 16 | +| **When it updates** | On state changes | Continuously while the task runs | |
| 17 | +| **Typical use case** | Progress bars, status badges, dashboards | AI chat responses, live logs, file processing | |
| 18 | +| **React hook** | [`useRealtimeRun`](/realtime/react-hooks/subscribe) | [`useRealtimeStream`](/realtime/react-hooks/streams) | |
| 19 | +| **Define in task code?** | No, automatic | Yes, using `streams.define()` | |
17 | 20 |
|
18 | | -- **Status changes** - queued → executing → completed, etc. |
19 | | -- **Metadata updates** - Custom progress tracking, status updates, user data, etc. ([React hooks](/realtime/react-hooks/subscribe#using-metadata-to-show-progress-in-your-ui) | [backend](/realtime/backend/subscribe#subscribe-to-metadata-updates-from-your-tasks)) |
20 | | -- **Tag changes** - When [tags](/tags) are added or removed from the run |
21 | | -- **Realtime Streams** - Stream real-time data from your tasks, perfect for AI/LLM outputs and progress updates. ([Learn more](/tasks/streams) | [React hooks](/realtime/react-hooks/streams) | [Backend](/realtime/backend/streams)) |
| 21 | +You can use both at the same time. Subscribe to a run's status with Realtime while also streaming AI output with Streams. |
| 22 | + |
| 23 | +## What you can subscribe to |
| 24 | + |
| 25 | +- **Specific runs** by run ID |
| 26 | +- **Runs with specific tags** (e.g., all runs tagged with `user:123`). [More on tags](/tags) |
| 27 | +- **Batch runs** within a specific batch |
| 28 | +- **Trigger + subscribe combos** that trigger a task and immediately subscribe (frontend only) |
| 29 | + |
| 30 | +Once subscribed, you get updates for: |
| 31 | + |
| 32 | +- **Status changes** like queued, executing, completed, failed |
| 33 | +- **Metadata updates** for custom progress tracking ([React hooks](/realtime/react-hooks/subscribe#using-metadata-to-show-progress-in-your-ui) | [backend](/realtime/backend/subscribe#subscribe-to-metadata-updates-from-your-tasks)) |
| 34 | +- **Tag changes** when [tags](/tags) are added or removed |
22 | 35 |
|
23 | 36 | ## Using Realtime in your applications |
24 | 37 |
|
25 | 38 | ### Authentication |
26 | 39 |
|
27 | | -All Realtime subscriptions require authentication so you can securely trigger and subscribe to runs. See our [authentication guide](/realtime/auth) for more details. |
| 40 | +All Realtime subscriptions require authentication. See the [authentication guide](/realtime/auth) for setup. |
| 41 | + |
| 42 | +### Frontend (React hooks) |
| 43 | + |
| 44 | +Use `@trigger.dev/react-hooks` to build UIs that update as runs execute. |
| 45 | + |
| 46 | +→ **[React hooks guide](/realtime/react-hooks/)** |
| 47 | + |
| 48 | +### Backend |
| 49 | + |
| 50 | +Subscribe to runs from your backend code, other tasks, or serverless functions. |
| 51 | + |
| 52 | +→ **[Backend guide](/realtime/backend)** |
| 53 | + |
| 54 | +## Frequently asked questions |
28 | 55 |
|
29 | | -### Frontend implementation |
| 56 | +### What's the difference between Realtime and Streams? |
30 | 57 |
|
31 | | -Use our React hooks to build real-time UIs that update as runs execute. Ideal for progress bars, status indicators, and live dashboards. |
| 58 | +Realtime tracks **run state**: status, metadata, and tags. Streams pipe **continuous data** (like AI completions or progress updates) from a running task to your frontend or backend. Use Realtime for "is my task done yet?" and Streams for "show me the AI output as it generates." |
32 | 59 |
|
33 | | -→ **[See our React hooks guide](/realtime/react-hooks/)** |
| 60 | +### Do I need to set up anything in my task for Realtime? |
34 | 61 |
|
35 | | -### Backend implementation |
| 62 | +No. Realtime subscriptions work automatically for any task. Just subscribe by run ID, tag, or batch from your frontend or backend. Streams require you to define them in your task code with `streams.define()`. |
36 | 63 |
|
37 | | -Use our server-side SDK to subscribe to runs from your backend code, other tasks, or serverless functions. Perfect for triggering workflows, sending notifications, or updating databases based on run status changes. |
| 64 | +### Can I use Realtime and Streams together? |
38 | 65 |
|
39 | | -→ **[See our Backend guide](/realtime/backend)** |
| 66 | +Yes. A common pattern is subscribing to a run's status with Realtime (to show a progress indicator) while also streaming AI output with Streams (to display tokens as they arrive). |
0 commit comments