@@ -5,12 +5,12 @@ description: "This guide will show you how to setup Trigger.dev in your existing
5
5
icon : " r"
6
6
---
7
7
8
- import Prerequisites from ' /snippets/framework-prerequisites.mdx' ;
9
- import CliInitStep from ' /snippets/step-cli-init.mdx' ;
10
- import CliDevStep from ' /snippets/step-cli-dev.mdx' ;
11
- import CliRunTestStep from ' /snippets/step-run-test.mdx' ;
12
- import CliViewRunStep from ' /snippets/step-view-run.mdx' ;
13
- import UsefulNextSteps from ' /snippets/useful-next-steps.mdx' ;
8
+ import Prerequisites from " /snippets/framework-prerequisites.mdx" ;
9
+ import CliInitStep from " /snippets/step-cli-init.mdx" ;
10
+ import CliDevStep from " /snippets/step-cli-dev.mdx" ;
11
+ import CliRunTestStep from " /snippets/step-run-test.mdx" ;
12
+ import CliViewRunStep from " /snippets/step-view-run.mdx" ;
13
+ import UsefulNextSteps from " /snippets/useful-next-steps.mdx" ;
14
14
import TriggerTaskRemix from " /snippets/trigger-tasks-remix.mdx" ;
15
15
import AddEnvironmentVariables from " /snippets/add-environment-variables.mdx" ;
16
16
import DeployingYourTask from " /snippets/deplopying-your-task.mdx" ;
@@ -20,10 +20,10 @@ import DeployingYourTask from "/snippets/deplopying-your-task.mdx";
20
20
## Initial setup
21
21
22
22
<Steps >
23
- <CliInitStep />
24
- <CliDevStep />
25
- <CliRunTestStep />
26
- <CliViewRunStep />
23
+ <CliInitStep />
24
+ <CliDevStep />
25
+ <CliRunTestStep />
26
+ <CliViewRunStep />
27
27
</Steps >
28
28
29
29
## Set your secret key locally
@@ -40,27 +40,24 @@ For more information on authenticating with Trigger.dev, see the [API keys page]
40
40
41
41
<Step title = " Create an API route" >
42
42
43
- Create a new file called ` api.hello-world.ts ` (or ` api.hello-world.js ` ) in the ` app/routes ` directory like this: ` app/routes/api.hello-world.ts ` .
43
+ Create a new file called ` api.hello-world.ts ` (or ` api.hello-world.js ` ) in the ` app/routes ` directory like this: ` app/routes/api.hello-world.ts ` .
44
44
45
45
</Step >
46
46
47
47
<Step title = " Add your task" >
48
48
49
- Add this code to your ` api.hello-world.ts ` file which imports your task:
49
+ Add this code to your ` api.hello-world.ts ` file which imports your task:
50
50
51
- ``` ts app/routes/api.hello-world.ts
52
- import type { helloWorldTask } from " ../../src/trigger/example" ;
53
- import { tasks } from " @trigger.dev/sdk/v3" ;
51
+ ``` ts app/routes/api.hello-world.ts
52
+ import type { helloWorldTask } from " ../../src/trigger/example" ;
53
+ import { tasks } from " @trigger.dev/sdk/v3" ;
54
54
55
- export async function loader() {
56
- const handle = await tasks .trigger <typeof helloWorldTask >(
57
- " hello-world" ,
58
- " James"
59
- );
55
+ export async function loader() {
56
+ const handle = await tasks .trigger <typeof helloWorldTask >(" hello-world" , " James" );
60
57
61
- return new Response (JSON .stringify (handle ), {
62
- headers: { " Content-Type" : " application/json" },
63
- });
58
+ return new Response (JSON .stringify (handle ), {
59
+ headers: { " Content-Type" : " application/json" },
60
+ });
64
61
}
65
62
```
66
63
@@ -74,13 +71,14 @@ For more information on authenticating with Trigger.dev, see the [API keys page]
74
71
75
72
</Steps >
76
73
77
- <AddEnvironmentVariables />
74
+ <AddEnvironmentVariables />
78
75
79
- <DeployingYourTask />
76
+ <DeployingYourTask />
80
77
81
78
## Deploying to Vercel Edge Functions
82
79
83
80
Before we start, it's important to note that:
81
+
84
82
- We'll be using a type-only import for the task to ensure compatibility with the edge runtime.
85
83
- The ` @trigger.dev/sdk/v3 ` package supports the edge runtime out of the box.
86
84
@@ -104,10 +102,7 @@ export const config = {
104
102
export async function action({ request }: { request: Request }) {
105
103
// This is where you'd authenticate the request
106
104
const payload = await request .json ();
107
- const handle = await tasks .trigger <typeof helloWorldTask >(
108
- " hello-world" ,
109
- payload
110
- );
105
+ const handle = await tasks .trigger <typeof helloWorldTask >(" hello-world" , payload );
111
106
return new Response (JSON .stringify (handle ), {
112
107
headers: { " Content-Type" : " application/json" },
113
108
});
@@ -155,7 +150,6 @@ Push your code to a Git repository and create a new project in the Vercel dashbo
155
150
156
151
</Step >
157
152
158
-
159
153
<Step title = " Add your Vercel environment variables" >
160
154
161
155
In the Vercel project settings, add your Trigger.dev secret key:
@@ -174,7 +168,10 @@ You can find this key in the Trigger.dev dashboard under API Keys and select the
174
168
175
169
Once you've added the environment variable, deploy your project to Vercel.
176
170
177
- <Note >Ensure you have also deployed your Trigger.dev task. See [ deploy your task step] ( /guides/frameworks/remix#deploying-your-task-to-trigger-dev ) .</Note >
171
+ <Note >
172
+ Ensure you have also deployed your Trigger.dev task. See [ deploy your task
173
+ step] ( /guides/frameworks/remix#deploying-your-task-to-trigger-dev ) .
174
+ </Note >
178
175
179
176
</Step >
180
177
@@ -200,5 +197,14 @@ The `vercel-build` script in `package.json` is specific to Remix projects on Ver
200
197
201
198
The ` runtime: "edge" ` configuration in the API route allows for better performance on Vercel's Edge Network.
202
199
200
+ ## Additional resources for Remix
201
+
202
+ <Card
203
+ title = " Remix - triggering tasks using webhooks"
204
+ icon = " R"
205
+ href = " /guides/frameworks/remix-webhooks"
206
+ >
207
+ How to create a webhook handler in a Remix app, and trigger a task from it.
208
+ </Card >
203
209
204
210
<UsefulNextSteps />
0 commit comments