Skip to content

Commit 59a0916

Browse files
committed
Run updates + streaming distinction
1 parent 30ea2c7 commit 59a0916

File tree

7 files changed

+48
-49
lines changed

7 files changed

+48
-49
lines changed

docs/realtime/backend/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import RealtimeExamplesCards from "/snippets/realtime-examples-cards.mdx";
1212

1313
| Category | What it does | Guide |
1414
|---|---|---|
15-
| **Progress and status** | Subscribe to run status, metadata, and tag changes | [Progress & status](/realtime/backend/subscribe) |
16-
| **Streaming data** | Read AI output, file chunks, or any continuous data from tasks | [Streaming](/realtime/backend/streams) |
15+
| **Run updates** | Subscribe to run status, metadata, and tag changes | [Run updates](/realtime/backend/subscribe) |
16+
| **Streaming** | Read AI output, file chunks, or any continuous data from tasks | [Streaming](/realtime/backend/streams) |
1717

1818
<Note>
1919
To learn how to emit streams from your tasks, see [Streaming data from tasks](/tasks/streams).

docs/realtime/backend/subscribe.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "Progress and status updates (backend)"
3-
sidebarTitle: "Progress & status"
2+
title: "Run updates (backend)"
3+
sidebarTitle: "Run updates"
44
description: "Subscribe to run status changes, metadata updates, and tag changes from your backend code using async iterators."
55
---
66

docs/realtime/how-it-works.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ sidebarTitle: "How it works"
44
description: "Technical architecture behind Trigger.dev's real-time run updates, built on Electric SQL and PostgreSQL syncing."
55
---
66

7+
This page covers the infrastructure behind **run updates** (status, metadata, tags). [Streaming](/tasks/streams) uses a separate transport.
8+
79
## Architecture
810

9-
The Realtime API is built on top of [Electric SQL](https://electric-sql.com/), an open-source PostgreSQL syncing engine. The Trigger.dev API wraps Electric SQL and provides a simple API to subscribe to [runs](/runs) and get real-time updates.
11+
The run updates system is built on top of [Electric SQL](https://electric-sql.com/), an open-source PostgreSQL syncing engine. The Trigger.dev API wraps Electric SQL and provides a simple API to subscribe to [runs](/runs) and get updates as they happen.
1012

1113
## Run changes
1214

docs/realtime/overview.mdx

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,63 @@
11
---
22
title: Realtime overview
33
sidebarTitle: Overview
4-
description: "Subscribe to run state changes (status, metadata, tags) in real time from your frontend or backend."
4+
description: "Get live run updates and stream data from background tasks to your frontend or backend. No polling."
55
---
66

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.
7+
**Realtime is the umbrella for everything live in Trigger.dev.** It covers two things: getting notified when a run's state changes, and streaming continuous data (like AI tokens) from a running task to your app.
88

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.
9+
Both use the same `@trigger.dev/react-hooks` package and the same authentication system. The difference is what they give you.
1010

11-
## How is Realtime different from Streams?
11+
## Run updates vs Streaming
1212

13-
| | Realtime subscriptions | Streams |
13+
| | Run updates | Streaming |
1414
|---|---|---|
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 |
15+
| **What you get** | Run state: status, metadata, tags | Continuous data you define (AI tokens, file chunks, progress) |
16+
| **When it fires** | On state changes | While the task runs, as data is produced |
17+
| **Use case** | Progress bars, status badges, dashboards | AI chat output, live logs, file processing |
1818
| **React hook** | [`useRealtimeRun`](/realtime/react-hooks/subscribe) | [`useRealtimeStream`](/realtime/react-hooks/streams) |
19-
| **Define in task code?** | No, automatic | Yes, using `streams.define()` |
19+
| **Setup in task code?** | No, automatic | Yes, using `streams.define()` |
20+
| **Infrastructure** | [Electric SQL](/realtime/how-it-works) (PostgreSQL sync) | Streams transport |
2021

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+
You can use both at the same time. Subscribe to a run's status (to show a progress bar) while also streaming AI output (to display tokens as they arrive).
2223

23-
## What you can subscribe to
24+
## Run updates
25+
26+
Subscribe to a run and your code gets called whenever its status, [metadata](/runs/metadata), or [tags](/tags) change. No setup needed in your task code.
27+
28+
You can subscribe to:
2429

2530
- **Specific runs** by run ID
26-
- **Runs with specific tags** (e.g., all runs tagged with `user:123`). [More on tags](/tags)
31+
- **Runs with specific tags** (e.g., all runs tagged with `user:123`)
2732
- **Batch runs** within a specific batch
2833
- **Trigger + subscribe combos** that trigger a task and immediately subscribe (frontend only)
2934

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
35-
36-
## Using Realtime in your applications
35+
[React hooks](/realtime/react-hooks/subscribe) | [Backend](/realtime/backend/subscribe)
3736

38-
### Authentication
37+
## Streaming
3938

40-
All Realtime subscriptions require authentication. See the [authentication guide](/realtime/auth) for setup.
39+
Define typed streams in your task, pipe data to them, and read that data from your frontend or backend as it's produced. You need to set up streams in your task code using `streams.define()`.
4140

42-
### Frontend (React hooks)
41+
[How to emit streams from tasks](/tasks/streams) | [React hooks](/realtime/react-hooks/streams) | [Backend](/realtime/backend/streams)
4342

44-
Use `@trigger.dev/react-hooks` to build UIs that update as runs execute.
43+
## Authentication
4544

46-
**[React hooks guide](/realtime/react-hooks/)**
45+
All Realtime hooks and functions require authentication. See the [authentication guide](/realtime/auth) for setup.
4746

48-
### Backend
49-
50-
Subscribe to runs from your backend code, other tasks, or serverless functions.
47+
## Frequently asked questions
5148

52-
**[Backend guide](/realtime/backend)**
49+
### How do I show a progress bar for a background task?
5350

54-
## Frequently asked questions
51+
Use [run metadata](/runs/metadata) to store progress data (like a percentage), then subscribe to the run with [`useRealtimeRun`](/realtime/react-hooks/subscribe). Your component re-renders on every metadata update.
5552

56-
### What's the difference between Realtime and Streams?
53+
### How do I stream AI/LLM responses from a background task?
5754

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."
55+
Define a stream in your task with `streams.define()`, pipe your AI SDK response to it, then consume it in React with [`useRealtimeStream`](/realtime/react-hooks/streams). See [Streaming data from tasks](/tasks/streams) for the full guide.
5956

60-
### Do I need to set up anything in my task for Realtime?
57+
### Do I need WebSockets or polling?
6158

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()`.
59+
No. Run updates are powered by [Electric SQL](/realtime/how-it-works) (HTTP-based PostgreSQL syncing). Streams use their own transport. The hooks handle connections automatically.
6360

64-
### Can I use Realtime and Streams together?
61+
### Can I use both run updates and streaming together?
6562

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).
63+
Yes. A common pattern: subscribe to run status with `useRealtimeRun` (progress indicator) while streaming AI output with `useRealtimeStream` (token-by-token display).

docs/realtime/react-hooks/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ Learn more about [generating and managing tokens in our authentication guide](/r
5858
| Hook category | What it does | Guide |
5959
|---|---|---|
6060
| **Trigger hooks** | Trigger tasks from the browser | [Triggering](/realtime/react-hooks/triggering) |
61-
| **Progress and status** | Subscribe to run status, metadata, and tags | [Progress and status](/realtime/react-hooks/subscribe) |
62-
| **Streaming data** | Consume AI output, file chunks, or any continuous data | [Streaming](/realtime/react-hooks/streams) |
61+
| **Run updates** | Subscribe to run status, metadata, and tags | [Run updates](/realtime/react-hooks/subscribe) |
62+
| **Streaming** | Consume AI output, file chunks, or any continuous data | [Streaming](/realtime/react-hooks/streams) |
6363
| **SWR hooks** | One-time fetch with caching (not recommended for most cases) | [SWR](/realtime/react-hooks/swr) |
6464

6565
## SWR vs Realtime hooks

docs/realtime/react-hooks/streams.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ For the newer `useRealtimeStream` hook, use the `throttleInMs` option instead (s
436436

437437
Define a typed stream in your task with `streams.define<string>()`, pipe your AI SDK response to it with `.pipe()`, then consume it in your component with `useRealtimeStream`. See [Streaming data from tasks](/tasks/streams) for the task-side setup.
438438

439-
### What's the difference between streaming and subscribing to runs?
439+
### What's the difference between streaming and run updates?
440440

441-
[Subscribing](/realtime/react-hooks/subscribe) tracks **run state** (status, metadata, tags). Streaming (this page) pipes **continuous data** your task produces. Use subscribing for progress bars and status badges. Use streaming for AI chat output, live logs, or file processing results. You can use both at the same time.
441+
[Run updates](/realtime/react-hooks/subscribe) track **run state** (status, metadata, tags). Streaming (this page) pipes **continuous data** your task produces. Use run updates for progress bars and status badges. Use streaming for AI chat output, live logs, or file processing results. You can use both at the same time.
442442

443443
### Can I send data back into a running task from React?
444444

docs/realtime/react-hooks/subscribe.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: "Progress and status updates in React"
3-
sidebarTitle: "Progress & status"
2+
title: "Run updates in React"
3+
sidebarTitle: "Run updates"
44
description: "Build progress bars, status indicators, and live dashboards by subscribing to background task updates from React components."
55
---
66

77
**Subscribe to a run and your component re-renders whenever its status, metadata, or tags change.** Build progress bars, deployment monitors, or any UI that needs to reflect what a background task is doing right now.
88

9-
For streaming continuous data (AI tokens, file chunks), see [Streaming data](/realtime/react-hooks/streams) instead.
9+
For streaming continuous data (AI tokens, file chunks), see [Streaming](/realtime/react-hooks/streams) instead.
1010

1111
## Trigger + subscribe combo hooks
1212

@@ -661,9 +661,9 @@ This allows you to change the ID of the subscription based on some state. Passin
661661

662662
Use `metadata.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](#using-metadata-to-show-progress-in-your-ui) above for a complete example.
663663

664-
### What's the difference between subscribing to runs and streaming data?
664+
### What's the difference between run updates and streaming?
665665

666-
Subscribing (this page) gives you **run state**: status, metadata, and tags. It's for progress bars, status badges, and dashboards. [Streaming](/realtime/react-hooks/streams) gives you **continuous data** like AI tokens or file chunks. Use subscribing for "how far along is my task?" and streaming for "show me the output as it generates."
666+
Run updates (this page) give you **run state**: status, metadata, and tags. They're for progress bars, status badges, and dashboards. [Streaming](/realtime/react-hooks/streams) 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."
667667

668668
### Can I subscribe to multiple runs at once?
669669

0 commit comments

Comments
 (0)