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
TRIGGER_API_URL=https://api.trigger.dev# this is only necessary if you are self-hosting
62
58
63
59
```
64
60
65
61
Replace `ENTER_YOUR_DEVELOPMENT_API_KEY_HERE` with the actual API key obtained from the previous step.
66
62
67
63
## Configuring the Trigger Client
68
64
69
-
To set up the Trigger Client for your project, follow these steps:
70
-
71
-
1.**Create Configuration File:**
72
-
73
-
In your project directory, create a configuration file named `trigger.ts` or `trigger.js`, depending on whether your project uses TypeScript (`.ts`) or JavaScript (`.js`).
74
-
75
-
2.**Choose Directory:**
76
-
77
-
Depending on your project structure, choose the appropriate directory for the configuration file. If your project uses a `src` directory, create the file within it. Otherwise, create it directly in the project root.
78
-
79
-
3.**Add Configuration Code:**
65
+
Create a file at `<root>/src/trigger.ts` or `<root>/trigger.ts` depending on whether you're using the `src` directory or not. `<root>` represents the root directory of your project.
80
66
81
-
Open the configuration file you created and add the following code:
67
+
Next, add the following code to the file which creates and exports a new `TriggerClient`:
82
68
83
-
```typescript
84
-
// trigger.ts (for TypeScript) or trigger.js (for JavaScript)
69
+
```typescript src/trigger.(ts/js)
70
+
// trigger.ts (for TypeScript) or trigger.js (for JavaScript)
85
71
86
-
import { TriggerClient } from"@trigger.dev/sdk";
72
+
import { TriggerClient } from"@trigger.dev/sdk";
87
73
88
-
exportconst client =newTriggerClient({
89
-
id: "my-app",
90
-
apiKey: process.env.TRIGGER_API_KEY,
91
-
apiUrl: process.env.TRIGGER_API_URL,
92
-
});
93
-
```
94
-
95
-
Replace **"my-app"** with an appropriate identifier for your project. The **apiKey** and **apiUrl** are obtained from the environment variables you set earlier.
96
-
97
-
4.**File Location:**
98
-
99
-
Depending on your project structure, save the configuration file in the appropriate location:
100
-
101
-
- If your project uses a **src** directory, save the file within the **src** directory.
102
-
- If your project does not use a **src** directory, save the file in the project root.
103
-
104
-
**Example Directory Structure with src:**
105
-
106
-
```
107
-
project-root/
108
-
├── src/
109
-
├── trigger.ts
110
-
├── other files...
111
-
```
112
-
113
-
**Example Directory Structure without src:**
114
-
115
-
```
116
-
project-root/
117
-
├── trigger.ts
118
-
├── other files...
119
-
```
74
+
exportconst client =newTriggerClient({
75
+
id: "my-app",
76
+
apiKey: process.env.TRIGGER_API_KEY,
77
+
apiUrl: process.env.TRIGGER_API_URL,
78
+
});
79
+
```
120
80
121
-
By following these steps, you'll configure the Trigger Client to work with your project, regardless of whether you have a separate **src**directory and whether you're using TypeScript or JavaScript files.
81
+
Replace **"my-app"**with an appropriate identifier for your project.
122
82
123
83
## Creating the API Route
124
84
@@ -238,18 +198,31 @@ Your `package.json` file might look something like this:
238
198
239
199
Replace **"my-app"** with the appropriate identifier you used during the step for creating the Trigger Client.
240
200
241
-
## Next Steps
201
+
## Running
242
202
243
-
Start your Next.js project locally, and then execute the `dev` CLI command to run Trigger.dev locally. You should run this command every time you want to use Trigger.dev locally.
203
+
### Run your Next.js app
244
204
245
-

205
+
Run your Next.js app locally, like you normally would. For example:
246
206
247
-
<Warning>
248
-
Make sure your Next.js site is running locally before continuing. You must also leave this `dev`
249
-
terminal command running while you develop.
250
-
</Warning>
207
+
<CodeGroup>
251
208
252
-
In a **new terminal window or tab** run:
209
+
```bash npm
210
+
npm run dev
211
+
```
212
+
213
+
```bash pnpm
214
+
pnpm run dev
215
+
```
216
+
217
+
```bash yarn
218
+
yarn run dev
219
+
```
220
+
221
+
</CodeGroup>
222
+
223
+
### Run the CLI 'dev' command
224
+
225
+
In a **_separate terminal window or tab_** run:
253
226
254
227
<CodeGroup>
255
228
@@ -271,9 +244,10 @@ yarn dlx @trigger.dev/cli@latest dev
271
244
You can optionally pass the port if you're not running on 3000 by adding
272
245
`--port 3001` to the end
273
246
</Note>
247
+
274
248
<Note>
275
249
You can optionally pass the hostname if you're not running on localhost by adding
276
-
`--hostname <host>`. Example, in case your Next.js is running on 0.0.0.0: `--hostname 0.0.0.0`.
250
+
`--hostname <host>`. Example, in case your Remix is running on 0.0.0.0: `--hostname 0.0.0.0`.
0 commit comments