How to manually setup Trigger.dev in your Express project
Start by installing the necessary packages in your Express.js project directory. You can use npm, pnpm, or yarn as your package manager.
To locate your development Server API key, login to the Trigger.dev
dashboard and select the Project you want to
connect to. Then click on the Environments & API Keys tab in the left menu.
You can copy your development Server API Key from the field at the top of this page.
(Your development key will start with tr_dev_
).
Create a .env
file at the root of your project and include your Trigger API key and URL like this:
Replace ENTER_YOUR_DEVELOPMENT_API_KEY_HERE
with the actual API key obtained from the previous step.
Create a file for your Trigger client, in this case we create it at <root>/trigger.(ts/js)
Replace "my-app" with an appropriate identifier for your project.
There are a few different options depending on how your Express project is configured.
Select the appropriate code example from below:
Create a Job file. In this case created <root>/jobs/example.(ts/js)
package.json
Inside the package.json
file, add the following configuration under the root object:
Replace "my-app" with the appropriate identifier you used in the trigger.js configuration file.
Run your Express app locally, like you normally would. For example:
npm run start
instead of devIn a separate terminal window or tab run:
You can optionally pass the port if you're not running on 3000 by adding
--port 3001
to the end
You can optionally pass the hostname if you're not running on localhost by adding
--hostname <host>
. Example, in case your Express is running on 0.0.0.0: --hostname 0.0.0.0
.