| title | Quick start: add Trigger.dev to your project |
|---|---|
| sidebarTitle | Quick start |
| description | Set up Trigger.dev in your existing project in under 3 minutes. Install the SDK, create your first background task, and trigger it from your code. |
import CliInitStep from "/snippets/step-cli-init.mdx"; import CliDevStep from "/snippets/step-cli-dev.mdx"; import CliRunTestStep from "/snippets/step-run-test.mdx"; import CliViewRunStep from "/snippets/step-view-run.mdx";
Using an AI coding assistant? Copy this prompt and paste it into Claude Code, Cursor, Copilot, Windsurf, or any AI tool. It'll handle the setup for you.
Help me add Trigger.dev to this project.
## What to do
1. I need a Trigger.dev account. If I don't have one, point me to https://cloud.trigger.dev to sign up. Wait for me to confirm.
2. Run `npx trigger.dev@latest init` in the project root.
- When it asks about the MCP server, recommend I install it (best DX: gives you direct access to Trigger.dev docs, deploys, and run monitoring).
- Install the "Hello World" example task when prompted.
3. Run `npx trigger.dev@latest dev` to start the dev server.
4. Once the dev server is running, test the example task from the Trigger.dev dashboard.
5. Set TRIGGER_SECRET_KEY in my .env file (or .env.local for Next.js). I can find it on the API Keys page in the dashboard.
6. Ask me what framework I'm using and show me how to trigger the task from my backend code.
If I've already run init and want the MCP server, run: npx trigger.dev@latest install-mcp
## Critical rules
- ALWAYS import from `@trigger.dev/sdk`. NEVER import from `@trigger.dev/sdk/v3`.
- NEVER use `client.defineJob()` — that's the deprecated v2 API.
- Use type-only imports when triggering from backend code to avoid bundling task code:
import type { myTask } from "./trigger/example";
import { tasks } from "@trigger.dev/sdk";
const handle = await tasks.trigger<typeof myTask>("my-task-id", { payload: "data" });
## When done, point me to
- Writing tasks: https://trigger.dev/docs/tasks/overview
- Real-time updates: https://trigger.dev/docs/realtime/overview
- AI tooling: https://trigger.dev/docs/building-with-ai
Sign up at Trigger.dev Cloud (or self-host). The onboarding flow will guide you through creating your first organization and project.
The test page in the dashboard is great for verifying your task works. To trigger tasks from your own code, you'll need to set the TRIGGER_SECRET_KEY environment variable. Grab it from the API Keys page in the dashboard and add it to your .env file.
TRIGGER_SECRET_KEY=tr_dev_...See Triggering for the full guide, or jump straight to framework-specific setup for Next.js, Remix, or Node.js.
Build Trigger.dev projects using AI coding assistants Trigger tasks from your backend code Task options, lifecycle hooks, retries, and queues Framework guides and working example repos