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
36
36
```
37
37
38
38
Replace `ENTER_YOUR_DEVELOPMENT_API_KEY_HERE` with the actual API key obtained from the previous step.
39
39
40
40
## Configuring the Trigger Client
41
41
42
-
To set up the Trigger Client for your project, follow these steps:
42
+
Create a file at `<root>/trigger.ts` or `<root>/src/trigger.ts`, depending on if your project uses a `src` directory, where `<root>` represents the root directory of your project.
43
43
44
-
1.**Create Configuration File:**
44
+
Next, add the following code to the file which creates and exports a new `TriggerClient`:
45
45
46
-
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`).
46
+
```typescript src/trigger.ts
47
+
import { TriggerClient } from"@trigger.dev/sdk";
47
48
48
-
2.**Choose Directory:**
49
-
50
-
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 or Otherwise, create it directly in the project root.
51
-
52
-
3.**Add Configuration Code:**
53
-
54
-
Open the configuration file you created and add the following code:
55
-
56
-
```typescript src/trigger.(ts/js)
57
-
// trigger.ts (for TypeScript) or trigger.js (for JavaScript)
58
-
59
-
import { TriggerClient } from"@trigger.dev/sdk";
60
-
61
-
exportconst client =newTriggerClient({
62
-
id: "my-app",
63
-
apiKey: import.meta.env.TRIGGER_API_KEY,
64
-
apiUrl: import.meta.env.TRIGGER_API_URL,
65
-
});
66
-
```
67
-
68
-
Replace **"my-app"** with an appropriate identifier for your project. The **apiKey** and **apiUrl** are obtained from the environment variables you set earlier.
69
-
70
-
4.**File Location:**
71
-
72
-
- You can save the file within the **src** directory or in the project rooot.
73
-
74
-
**Example Directory Structure with src:**
75
-
76
-
```
77
-
project-root/
78
-
├── src/
79
-
├── trigger.ts
80
-
├── other files...
81
-
```
82
-
83
-
**Example Directory Structure without src:**
84
-
85
-
```
86
-
project-root/
87
-
├── trigger.ts
88
-
├── other files...
89
-
```
49
+
exportconst client =newTriggerClient({
50
+
id: "my-astro-app",
51
+
apiKey: import.meta.env.TRIGGER_API_KEY,
52
+
apiUrl: import.meta.env.TRIGGER_API_URL,
53
+
});
54
+
```
90
55
91
-
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.
56
+
Replace **"my-astro-app"**with an appropriate identifier for your project.
92
57
93
-
## Update the astro.config file to enable ssr
58
+
## Update the astro.config file to enable SSR (Server Side Rendering)
94
59
95
-
- You need to enable ssr to use API endpoints (which are required by Trigger.dev).
60
+
- You need to enable SSR to use API endpoints (which are required by Trigger.dev).
0 commit comments