@trigger.dev/react-hooks package and the same authentication system. The difference is what they give you.
Run updates vs Streaming
| Run updates | Streaming | |
|---|---|---|
| What you get | Run state: status, metadata, tags | Continuous data you define (AI tokens, file chunks, progress) |
| When it fires | On state changes | While the task runs, as data is produced |
| Use case | Progress bars, status badges, dashboards | AI chat output, live logs, file processing |
| React hook | useRealtimeRun | useRealtimeStream |
| Setup in task code? | No, automatic | Yes, using streams.define() |
| Infrastructure | Electric SQL (PostgreSQL sync) | Streams transport |
Run updates
Subscribe to a run and your code gets called whenever its status, metadata, or tags change. No setup needed in your task code. You can subscribe to:- Specific runs by run ID
- Runs with specific tags (e.g., all runs tagged with
user:123) - Batch runs within a specific batch
- Trigger + subscribe combos that trigger a task and immediately subscribe (frontend only)
Streaming
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 usingstreams.define().
→ How to emit streams from tasks | React hooks | Backend
Authentication
All Realtime hooks and functions require authentication. See the authentication guide for setup.Frequently asked questions
How do I show a progress bar for a background task?
Use run metadata to store progress data (like a percentage), then subscribe to the run withuseRealtimeRun. Your component re-renders on every metadata update.
How do I stream AI/LLM responses from a background task?
Define a stream in your task withstreams.define(), pipe your AI SDK response to it, then consume it in React with useRealtimeStream. See Streaming data from tasks for the full guide.
Do I need WebSockets or polling?
No. Run updates are powered by Electric SQL (HTTP-based PostgreSQL syncing). Streams use their own transport. The hooks handle connections automatically.Can I use both run updates and streaming together?
Yes. A common pattern: subscribe to run status withuseRealtimeRun (progress indicator) while streaming AI output with useRealtimeStream (token-by-token display).
