Start creating Jobs in 5 minutes in your Next.js project.
This quick start guide will get you up and running with Trigger.dev.
Need to create a new Next.js project to add Trigger.dev to?
No problem, create a blank project by running the create-next-app
command in your terminal then continue with this quickstart guide as normal:
Trigger.dev works with either the Pages or App Router configuration.
You can either:
Once you've created an account, follow the steps in the app to:
Go to the "Environments & API Keys" page in your project.
Copy the DEV
SERVER API key.
The easiest way to get started it to use the CLI. It will add Trigger.dev to your existing project, setup a route and give you an example file.
In a terminal window run:
It will ask you a couple of questions
Make sure your site is running locally, we will connect to it to register your Jobs.
The CLI dev
command allows the Trigger.dev service to send messages to your site. This is required for registering Jobs, triggering them and running tasks. To achieve this it creates a tunnel (using ngrok) so Trigger.dev can send messages to your machine.
You should leave the dev
command running when you're developing.
In a new terminal window or tab run:
You can optionally pass the port if you're not running on the default port by adding
--port 3001
to the end.
Experiencing an error? This could be due to middleware.
Instructions of how to resolve any issues due to middleware here
Advanced: Run your Next.js server together with the CLI
You can modify your package.json
to run both the Next.js server and the CLI dev
command together.
concurrently
package:package.json
file’s dev
script.The CLI init command created a simple Job for you. There will be a new file either src/jobs/examples.(ts/js)
or jobs/examples.(ts/js)
.
In there is this Job:
If you navigate to your Trigger.dev project you will see this Job in the “Jobs” section:
There are two way to trigger this Job.
Click into the Job and then open the "Test" tab. You should see this page:
This Job doesn't have a payload schema (meaning it takes an empty object), so you can simple click the "Run test" button.
Congratulations, you should get redirected so you can see your first Run!
A Guide for how to create your first real Job
Learn more about how Trigger.dev works and how it can help you.
Find code examples for many popular APIs. These can be copied / modified for use in your own projects.
Struggling getting setup or have a question? We're here to help.