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
@@ -23,4 +26,139 @@ import UsefulNextSteps from '/snippets/useful-next-steps.mdx';
23
26
<CliViewRunStep />
24
27
</Steps>
25
28
29
+
## Set your secret key locally
30
+
31
+
Set your `TRIGGER_SECRET_KEY` environment variable in your `.env` file. This key is used to authenticate with Trigger.dev, so you can trigger runs from your Remix app. Visit the API Keys page in the dashboard and select the DEV secret key.
32
+
33
+

34
+
35
+
For more information on authenticating with Trigger.dev, see the [API keys page](/apikeys).
36
+
37
+
## Triggering your task in Remix
38
+
39
+
<Steps>
40
+
41
+
<Steptitle="Create an API route">
42
+
43
+
Create a new file called `api.trigger.ts` (or `api.trigger.js`) in the `app/routes` directory like this: `app/routes/api.trigger.ts`.
44
+
45
+
</Step>
46
+
47
+
<Steptitle="Add your task">
48
+
49
+
Add this code to your `api.trigger.ts` file which imports your task:
Push your code to a Git repository and create a new project in the Vercel dashboard. Select your repository and follow the prompts to complete the deployment.
123
+
124
+
</Step>
125
+
126
+
127
+
<Steptitle="Add your Vercel environment variables">
128
+
129
+
In the Vercel project settings, add your Trigger.dev secret key:
130
+
131
+
```bash
132
+
TRIGGER_SECRET_KEY=your-secret-key
133
+
```
134
+
135
+
You can find this key in the Trigger.dev dashboard under API Keys and select the environment key you want to use.
136
+
137
+

138
+
139
+
</Step>
140
+
141
+
<Steptitle="Deploy your project">
142
+
143
+
Once you've added the environment variable, deploy your project to Vercel.
144
+
145
+
<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>
146
+
147
+
</Step>
148
+
149
+
<Steptitle="Test your task in production">
150
+
151
+
After deployment, visit your Vercel deployment URL followed by `/api/trigger` (e.g., `https://your-app.vercel.app/api/trigger`) to test the Trigger.dev task in production.
152
+
153
+
</Step>
154
+
155
+
</Steps>
156
+
157
+
### Additional notes
158
+
159
+
The `vercel-build` script in `package.json` is specific to Remix projects on Vercel, ensuring that static assets are correctly copied to the build output.
160
+
161
+
The `runtime: "edge"` configuration in the API route allows for better performance on Vercel's Edge Network.
If you have any environment variables in your tasks, be sure to add them in the dashboard so deployed code runs successfully. In Node.js, these environment variables are accessed in your code using `process.env.MY_ENV_VAR`.
4
+
5
+
In the sidebar select the "Environment Variables" page, then press the "New environment variable"
For this guide, we'll manually deploy your task by running the [CLI deploy command](/cli-deploy) below. Other ways to deploy are listed in the next section.
4
+
5
+
<CodeGroup>
6
+
7
+
```bash npm
8
+
npx trigger.dev@latest deploy
9
+
```
10
+
11
+
```bash pnpm
12
+
pnpm dlx trigger.dev@latest deploy
13
+
```
14
+
15
+
```bash yarn
16
+
yarn dlx trigger.dev@latest deploy
17
+
```
18
+
19
+
</CodeGroup>
20
+
21
+
### Other ways to deploy
22
+
23
+
<Tabs>
24
+
25
+
<Tabtitle="GitHub Actions">
26
+
27
+
Use GitHub Actions to automatically deploy your tasks whenever new code is pushed and when the `trigger` directory has changes in it. Follow [this guide](/github-actions) to set up GitHub Actions.
28
+
29
+
</Tab>
30
+
31
+
<Tabtitle="Vercel Integration">
32
+
33
+
We're working on adding an official [Vercel integration](/vercel-integration) which you can follow the progress of [here](https://feedback.trigger.dev/p/vercel-integration-3).
Run the dev server from Step 2. of the [Initial Setup](/guides/frameworks/remix#initial-setup) section above if it's not already running:
20
+
21
+
<CodeGroup>
22
+
23
+
```bash npm
24
+
npx trigger.dev@latest dev
25
+
```
26
+
27
+
```bash pnpm
28
+
pnpm dlx trigger.dev@latest dev
29
+
```
30
+
31
+
```bash yarn
32
+
yarn dlx trigger.dev@latest dev
33
+
```
34
+
35
+
</CodeGroup>
36
+
37
+
Now visit the URL in your browser to trigger the task. Ensure the port number is the same as the one you're running your Remix app on. For example, if you're running your Remix app on port 3000, visit:
38
+
39
+
```bash
40
+
http://localhost:3000/api/trigger
41
+
```
42
+
43
+
You should see the CLI log the task run with a link to view the logs in the dashboard.
44
+
45
+

46
+
47
+
Visit the [Trigger.dev dashboard](https://cloud.trigger.dev) to see your run.
0 commit comments