Installation
Install the@trigger.dev/react-hooks
package in your project:
Authentication
All hooks require authentication with a Public Access Token. Pass the token via theaccessToken
option:
Available hooks
We provide several categories of hooks:- Triggering hooks - Trigger tasks from your frontend application
- Subscribe hooks - Subscribe to runs, batches, metadata, and more
- Streams hooks - Subscribe to real-time streams from your tasks
- SWR hooks - Fetch data once and cache it using SWR
SWR vs Realtime hooks
We offer two “styles” of hooks: SWR and Realtime. The SWR hooks use the swr library to fetch data once and cache it. The Realtime hooks use Trigger.dev Realtime to subscribe to updates in real-time.It can be a little confusing which one to use because swr can also be
configured to poll for updates. But because of rate-limits and the way the Trigger.dev API works,
we recommend using the Realtime hooks for most use-cases.