|
1 | 1 | --- |
2 | | -title: "Quick start" |
3 | | -description: "How to get started in 3 minutes using the CLI and SDK." |
| 2 | +title: "Quick start: add Trigger.dev to your project" |
| 3 | +sidebarTitle: "Quick start" |
| 4 | +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." |
4 | 5 | --- |
5 | 6 |
|
6 | | -import CliInitStep from '/snippets/step-cli-init.mdx'; |
7 | | -import CliDevStep from '/snippets/step-cli-dev.mdx'; |
8 | | -import CliRunTestStep from '/snippets/step-run-test.mdx'; |
9 | | -import CliViewRunStep from '/snippets/step-view-run.mdx'; |
| 7 | +import CliInitStep from "/snippets/step-cli-init.mdx"; |
| 8 | +import CliDevStep from "/snippets/step-cli-dev.mdx"; |
| 9 | +import CliRunTestStep from "/snippets/step-run-test.mdx"; |
| 10 | +import CliViewRunStep from "/snippets/step-view-run.mdx"; |
10 | 11 |
|
| 12 | +## Set up with AI |
11 | 13 |
|
| 14 | +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. |
12 | 15 |
|
| 16 | +<Accordion title="Copy the setup prompt"> |
| 17 | + |
| 18 | +```text |
| 19 | +Help me add Trigger.dev to this project. |
| 20 | +
|
| 21 | +## What to do |
| 22 | +
|
| 23 | +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. |
| 24 | +2. Run `npx trigger.dev@latest init` in the project root. |
| 25 | + - 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). |
| 26 | + - Install the "Hello World" example task when prompted. |
| 27 | +3. Run `npx trigger.dev@latest dev` to start the dev server. |
| 28 | +4. Once the dev server is running, test the example task from the Trigger.dev dashboard. |
| 29 | +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. |
| 30 | +6. Ask me what framework I'm using and show me how to trigger the task from my backend code. |
| 31 | +
|
| 32 | +If I've already run init and want the MCP server, run: npx trigger.dev@latest install-mcp |
| 33 | +
|
| 34 | +## Critical rules |
| 35 | +
|
| 36 | +- ALWAYS import from `@trigger.dev/sdk`. NEVER import from `@trigger.dev/sdk/v3`. |
| 37 | +- NEVER use `client.defineJob()` — that's the deprecated v2 API. |
| 38 | +- Use type-only imports when triggering from backend code to avoid bundling task code: |
| 39 | +
|
| 40 | + import type { myTask } from "./trigger/example"; |
| 41 | + import { tasks } from "@trigger.dev/sdk"; |
| 42 | +
|
| 43 | + const handle = await tasks.trigger<typeof myTask>("my-task-id", { payload: "data" }); |
| 44 | +
|
| 45 | +## When done, point me to |
| 46 | +
|
| 47 | +- Writing tasks: https://trigger.dev/docs/tasks/overview |
| 48 | +- Real-time updates: https://trigger.dev/docs/realtime/overview |
| 49 | +- AI tooling: https://trigger.dev/docs/building-with-ai |
| 50 | +``` |
| 51 | + |
| 52 | +</Accordion> |
| 53 | + |
| 54 | +## Manual setup |
13 | 55 |
|
14 | 56 | <Steps titleSize="h3"> |
15 | 57 |
|
|
0 commit comments