You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/frameworks/nextjs.mdx
+146-1Lines changed: 146 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -248,12 +248,156 @@ Here are the steps to trigger your task in the Next.js App and Pages router and
248
248
249
249
<DeployingYourTask />
250
250
251
-
## Troubleshooting
251
+
## Troubleshooting & extra resources
252
252
253
253
<NextjsTroubleshootingMissingApiKey/>
254
254
<NextjsTroubleshootingButtonSyntax/>
255
255
<WorkerFailedToStartWhenRunningDevCommand/>
256
256
257
+
### Revalidation from your Trigger.dev tasks
258
+
259
+
[Revalidation](https://vercel.com/docs/incremental-static-regeneration/quickstart#on-demand-revalidation) allows you to purge the cache for an ISR route. To revalidate an ISR route from a Trigger.dev task, you have to set up a handler for the `revalidate` event. This is an API route that you can add to your Next.js app.
260
+
261
+
This handler will run the `revalidatePath` function from Next.js, which purges the cache for the given path.
262
+
263
+
The handlers are slightly different for the App and Pages router:
264
+
265
+
#### Revalidation helper: App Router
266
+
267
+
If you are using the App router, create a new revalidation route at `app/api/revalidate/path/route.ts`:
This task takes a `path` as a payload and will revalidate the path you specify, using the handler you set up previously.
331
+
332
+
<Note>
333
+
334
+
To run this task locally you will need to set the `REVALIDATION_SECRET` environment variable in your `.env.local` file (or `.env` file if using Pages router).
335
+
336
+
To run this task in production, you will need to set the `REVALIDATION_SECRET` environment variable in Vercel, in your project settings, and also in your environment variables in the Trigger.dev dashboard.
0 commit comments