How to manually setup Trigger.dev in your SvelteKit project
tr_dev_
).
.env
file at the root of your project and include your Trigger API key and URL like this:
ENTER_YOUR_DEVELOPMENT_API_KEY_HERE
with the actual API key obtained from the previous step.
<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.
Next, add the following code to the file which creates and exports a new TriggerClient
:
+server.(ts/js)
within the src/routes/api/trigger
directory, and add the following code:
jobs
alongside your src
directoryjobs
folder, add two files named example.(ts/js)
and index.(ts/js)
.jobs
folder and exporting them in the src/jobs/index
file.
For example, in index.(ts/js)
, you can export other job files like this:
package.json
package.json
file, add the following configuration under the root object:
package.json
file might look something like this:
--host
flag to allow the Trigger.dev CLI to connect to your app.
For example:
--port 5173
to the end--hostname <host>
. Example, in case your Sveltekit app is running on 0.0.0.0: --hostname 0.0.0.0
.