Skip to content

Commit a9275d0

Browse files
committed
Various fixes
1 parent c00dae0 commit a9275d0

File tree

7 files changed

+65
-9
lines changed

7 files changed

+65
-9
lines changed

docs/docs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,10 @@
642642
"source": "/trigger-config",
643643
"destination": "/config/config-file"
644644
},
645+
{
646+
"source": "/guides/frameworks",
647+
"destination": "/guides/frameworks/nextjs"
648+
},
645649
{
646650
"source": "/guides/frameworks/introduction",
647651
"destination": "/guides/introduction"

docs/errors-retrying.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ You can configure retrying in two ways:
1212
1. In your [trigger.config file](/config/config-file) you can set the default retrying behavior for all tasks.
1313
2. On each task you can set the retrying behavior.
1414

15+
<Note>Task-level retry settings override the defaults in your `trigger.config` file.</Note>
16+
1517
<Note>
1618
By default when you create your project using the CLI init command we disabled retrying in the DEV
1719
environment. You can enable it in your [trigger.config file](/config/config-file).

docs/guides/frameworks/nextjs.mdx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For more information on authenticating with Trigger.dev, see the [API keys page]
4545

4646
## Triggering your task in Next.js
4747

48-
Here are the steps to trigger your task in the Next.js App and Pages router and Server Actions. Alternatively, check out this repo for a [full working example](https://github.com/triggerdotdev/example-projects/tree/main/nextjs/server-actions/my-app) of a Next.js app with a Trigger.dev task triggered using a Server Action.
48+
Here are the steps to trigger your task in the Next.js App and Pages router and Server Actions.
4949

5050
<Tabs>
5151

@@ -432,5 +432,18 @@ You can test your revalidation task in the Trigger.dev dashboard on the testing
432432
<NextjsTroubleshootingMissingApiKey/>
433433
<NextjsTroubleshootingButtonSyntax/>
434434

435+
## Realtime updates with React hooks
436+
437+
The `@trigger.dev/react-hooks` package lets you subscribe to task runs from your React components. Show progress bars, stream AI responses, or display run status in real time.
438+
439+
<CardGroup cols={2}>
440+
<Card title="React hooks" icon="react" href="/realtime/react-hooks/overview">
441+
Hooks for subscribing to runs, streaming data, and triggering tasks from the frontend.
442+
</Card>
443+
<Card title="Streams" icon="wave-pulse" href="/tasks/streams">
444+
Pipe continuous data (like AI completions) from your tasks to the client while they run.
445+
</Card>
446+
</CardGroup>
447+
435448
<VercelDocsCards />
436449
<UsefulNextSteps />

docs/guides/frameworks/remix.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ The `vercel-build` script in `package.json` is specific to Remix projects on Ver
197197

198198
The `runtime: "edge"` configuration in the API route allows for better performance on Vercel's Edge Network.
199199

200+
## Realtime updates with React hooks
201+
202+
The `@trigger.dev/react-hooks` package lets you subscribe to task runs from your React components. Show progress bars, stream AI responses, or display run status in real time.
203+
204+
<CardGroup cols={2}>
205+
<Card title="React hooks" icon="react" href="/realtime/react-hooks/overview">
206+
Hooks for subscribing to runs, streaming data, and triggering tasks from the frontend.
207+
</Card>
208+
<Card title="Streams" icon="wave-pulse" href="/tasks/streams">
209+
Pipe continuous data (like AI completions) from your tasks to the client while they run.
210+
</Card>
211+
</CardGroup>
212+
200213
## Additional resources for Remix
201214

202215
<Card

docs/quick-start.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,30 @@ Sign up at [Trigger.dev Cloud](https://cloud.trigger.dev) (or [self-host](/open-
2626

2727
</Steps>
2828

29+
## Triggering tasks from your app
30+
31+
The test page in the dashboard is great for verifying your task works. To trigger tasks from your own code, you'll need to set the `TRIGGER_SECRET_KEY` environment variable. Grab it from the API Keys page in the dashboard and add it to your `.env` file.
32+
33+
```bash .env
34+
TRIGGER_SECRET_KEY=tr_dev_...
35+
```
36+
37+
See [Triggering](/triggering) for the full guide, or jump straight to framework-specific setup for [Next.js](/guides/frameworks/nextjs), [Remix](/guides/frameworks/remix), or [Node.js](/guides/frameworks/nodejs).
38+
2939
## Next steps
3040

3141
<CardGroup cols={2}>
3242
<Card title="Building with AI" icon="brain" href="/building-with-ai">
33-
Learn how to build Trigger.dev projects using AI coding assistants
43+
Build Trigger.dev projects using AI coding assistants
3444
</Card>
3545
<Card title="How to trigger your tasks" icon="bolt" href="/triggering">
36-
Learn how to trigger tasks from your code.
46+
Trigger tasks from your backend code
3747
</Card>
3848
<Card title="Writing tasks" icon="wand-magic-sparkles" href="/tasks/overview">
39-
Tasks are the core of Trigger.dev. Learn what they are and how to write them.
49+
Task options, lifecycle hooks, retries, and queues
4050
</Card>
4151
<Card title="Guides and example projects" icon="books" href="/guides/introduction">
42-
Guides and examples for triggering tasks from your code.
52+
Framework guides and working example repos
4353
</Card>
4454

4555
</CardGroup>

docs/tasks/overview.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Anything you return from the `run` function will be the result of the task. Data
6464

6565
### `retry` options
6666

67-
A task is retried if an error is thrown, by default we retry 3 times.
67+
A task is retried if an error is thrown. By default, we retry 3 times.
6868

6969
You can set the number of retries and the delay between retries in the `retry` field:
7070

@@ -84,6 +84,16 @@ export const taskWithRetries = task({
8484
});
8585
```
8686

87+
| Option | What it does |
88+
|---|---|
89+
| `maxAttempts` | Total number of attempts (including the first). Default: 3 |
90+
| `factor` | Exponential backoff multiplier. Each retry delay = previous delay x factor. With `factor: 1.8` and `minTimeoutInMs: 500`, retries wait 500ms, 900ms, 1620ms, etc. |
91+
| `minTimeoutInMs` | Delay before the first retry |
92+
| `maxTimeoutInMs` | Cap on the delay between retries |
93+
| `randomize` | Add jitter to retry delays to prevent multiple failing tasks from retrying in lockstep |
94+
95+
<Note>Task-level retry settings override the defaults in your `trigger.config` file.</Note>
96+
8797
For more information read [the retrying guide](/errors-retrying).
8898

8999
It's also worth mentioning that you can [retry a block of code](/errors-retrying) inside your tasks as well.
@@ -145,7 +155,7 @@ You can register global lifecycle hooks that are executed for all runs, regardle
145155
```ts
146156
import { tasks } from "@trigger.dev/sdk";
147157

148-
tasks.onStart(({ ctx, payload, task }) => {
158+
tasks.onStartAttempt(({ ctx, payload, task }) => {
149159
console.log("Run started", ctx.run);
150160
});
151161

@@ -160,12 +170,12 @@ tasks.onFailure(({ ctx, error }) => {
160170

161171
### `init.ts`
162172

163-
If you create a `init.ts` file at the root of your trigger directory, it will be automatically loaded when a task is executed. This is useful if you want to register global lifecycle hooks, or initialize a database connection, etc.
173+
If you create an `init.ts` file at the root of your trigger directory, it will be automatically loaded when a task is executed. This is useful for registering global lifecycle hooks, initializing a database connection, etc.
164174

165175
```ts init.ts
166176
import { tasks } from "@trigger.dev/sdk";
167177

168-
tasks.onStart(({ ctx, payload, task }) => {
178+
tasks.onStartAttempt(({ ctx, payload, task }) => {
169179
console.log("Run started", ctx.run);
170180
});
171181
```

docs/triggering.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Trigger tasks **from inside a another task**:
2929

3030
When you trigger a task from your backend code, you need to set the `TRIGGER_SECRET_KEY` environment variable. If you're [using a preview branch](/deployment/preview-branches), you also need to set the `TRIGGER_PREVIEW_BRANCH` environment variable. You can find the value on the API keys page in the Trigger.dev dashboard. [More info on API keys](/apikeys).
3131

32+
<Note>
33+
**Which trigger pattern should I use?** If your triggering code can import the task definition (same codebase), use `yourTask.trigger()` for full type safety. Use `tasks.trigger()` with a type-only import when the task runs in a separate service or you need to avoid bundling task code into your app (common in Next.js). Both do the same thing at runtime.
34+
</Note>
35+
3236
<Note>
3337
If you are using Next.js Server Actions [you'll need to be careful with
3438
bundling](/guides/frameworks/nextjs#triggering-your-task-in-next-js).

0 commit comments

Comments
 (0)