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/v3/triggering.mdx
+70Lines changed: 70 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ You can trigger any task from your backend code, using either `trigger()` or `ba
23
23
Trigger.dev API key to the world.
24
24
</Note>
25
25
26
+
You can use Next.js Server Actions but [you need to be careful with bundling](#next-js-server-actions).
27
+
26
28
### Authentication
27
29
28
30
When you trigger a task from your backend code, you need to set the `TRIGGER_SECRET_KEY` environment variable. You can find the value on the API keys page in the Trigger.dev dashboard. [More info on API keys](/v3/apikeys).
Server Actions allow you to call your backend code without creating API routes. This is very useful for triggering tasks but you need to be careful you don't accidentally bundle the Trigger.dev SDK into your frontend code.
197
+
198
+
If you see an error like this then you've bundled `@trigger.dev/sdk` into your frontend code:
199
+
200
+
```bash
201
+
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).
202
+
Module build failed: UnhandledSchemeError: Reading from "node:process" is not handled by plugins (Unhandled scheme).
203
+
Webpack supports "data:" and "file:" URIs by default.
204
+
You may need an additional plugin to handle "node:" URIs.
205
+
```
206
+
207
+
When you use server actions that use `@trigger.dev/sdk`:
208
+
209
+
- The file can't have any React components in it.
210
+
- The file should have `"use server"` on the first line.
211
+
212
+
Here's an example of how to do it with a component that calls the server action and the actions file:
0 commit comments