$npx -y skills add get-convex/agent-skills --skill convex-quickstartCreates or adds Convex to an app. Use for new Convex projects, npm create convex@latest, frontend setup, env vars, or the first npx convex dev run.
| 1 | # Convex Quickstart |
| 2 | |
| 3 | Set up a working Convex project as fast as possible. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Starting a brand new project with Convex |
| 8 | - Adding Convex to an existing React, Next.js, Vue, Svelte, or other app |
| 9 | - Scaffolding a Convex app for prototyping |
| 10 | |
| 11 | ## When Not to Use |
| 12 | |
| 13 | - The project already has Convex installed and `convex/` exists - just start |
| 14 | building |
| 15 | - You only need to add auth to an existing Convex app - use the |
| 16 | `convex-setup-auth` skill |
| 17 | |
| 18 | ## Workflow |
| 19 | |
| 20 | 1. Determine the starting point: new project or existing app |
| 21 | 2. If new project, pick a template and scaffold with `npm create convex@latest` |
| 22 | 3. If existing app, install `convex` and wire up the provider |
| 23 | 4. Run `npx convex dev --once` to provision a local anonymous deployment, push |
| 24 | the current `convex/` code, typecheck it, and regenerate types — all in one |
| 25 | shot, exiting cleanly. The output tells the agent whether the schema and |
| 26 | functions are valid. |
| 27 | 5. Ask the user (or, for cloud agents, start in the background) `npm run dev` — |
| 28 | Convex templates wire the watcher and the frontend into a single command. If |
| 29 | the project has no combined dev script, use `npx convex dev` for the watcher |
| 30 | and run the frontend separately. |
| 31 | 6. Verify the setup works |
| 32 | |
| 33 | ## Path 1: New Project (Recommended) |
| 34 | |
| 35 | Use the official scaffolding tool. It creates a complete project with the |
| 36 | frontend framework, Convex backend, and all config wired together. |
| 37 | |
| 38 | ### Pick a template |
| 39 | |
| 40 | | Template | Stack | |
| 41 | | -------------------------- | ----------------------------------------- | |
| 42 | | `react-vite-shadcn` | React + Vite + Tailwind + shadcn/ui | |
| 43 | | `nextjs-shadcn` | Next.js App Router + Tailwind + shadcn/ui | |
| 44 | | `react-vite-clerk-shadcn` | React + Vite + Clerk auth + shadcn/ui | |
| 45 | | `nextjs-clerk` | Next.js + Clerk auth | |
| 46 | | `nextjs-convexauth-shadcn` | Next.js + Convex Auth + shadcn/ui | |
| 47 | | `nextjs-lucia-shadcn` | Next.js + Lucia auth + shadcn/ui | |
| 48 | | `bare` | Convex backend only, no frontend | |
| 49 | |
| 50 | If the user has not specified a preference, default to `react-vite-shadcn` for |
| 51 | simple apps or `nextjs-shadcn` for apps that need SSR or API routes. |
| 52 | |
| 53 | You can also use any GitHub repo as a template: |
| 54 | |
| 55 | ```bash |
| 56 | npm create convex@latest my-app -- -t owner/repo |
| 57 | npm create convex@latest my-app -- -t owner/repo#branch |
| 58 | ``` |
| 59 | |
| 60 | ### Scaffold the project |
| 61 | |
| 62 | Always pass the project name and template flag to avoid interactive prompts: |
| 63 | |
| 64 | ```bash |
| 65 | npm create convex@latest my-app -- -t react-vite-shadcn |
| 66 | cd my-app |
| 67 | npm install |
| 68 | ``` |
| 69 | |
| 70 | The scaffolding tool creates files but does not run `npm install`, so you must |
| 71 | run it yourself. |
| 72 | |
| 73 | To scaffold in the current directory (if it is empty): |
| 74 | |
| 75 | ```bash |
| 76 | npm create convex@latest . -- -t react-vite-shadcn |
| 77 | npm install |
| 78 | ``` |
| 79 | |
| 80 | ### Provision the deployment and push code |
| 81 | |
| 82 | Run this yourself — it is a one-shot command that exits cleanly: |
| 83 | |
| 84 | ```bash |
| 85 | npx convex dev --once |
| 86 | ``` |
| 87 | |
| 88 | In a non-TTY environment (which is true for almost every agent run), this: |
| 89 | |
| 90 | - Provisions an _anonymous_ local Convex backend bound to `127.0.0.1`. No |
| 91 | browser login, no team/project prompts. |
| 92 | - Writes `CONVEX_DEPLOYMENT` and the framework's `*_CONVEX_URL` variables to |
| 93 | `.env.local`. |
| 94 | - Generates `convex/_generated/`. |
| 95 | - Pushes the current `convex/` code to the deployment, **typechecks it**, and |
| 96 | **validates the schema**. The agent reads this output to find out if the code |
| 97 | it just wrote is broken. |
| 98 | |
| 99 | To be explicit (recommended), set `CONVEX_AGENT_MODE=anonymous` so the behavior |
| 100 | does not depend on TTY detection: |
| 101 | |
| 102 | ```bash |
| 103 | CONVEX_AGENT_MODE=anonymous npx convex dev --once |
| 104 | ``` |
| 105 | |
| 106 | The deployment lives under `~/.convex/` and persists across runs. Re-running |
| 107 | `convex dev --once` after editing `convex/` files is the agent's main feedback |
| 108 | loop while the user-launched `npm run dev` is not in use. |
| 109 | |
| 110 | If the template's `package.json` defines a `predev` script (Convex Auth |
| 111 | templates and similar do), `npm run predev` runs `convex init` plus any one-time |
| 112 | setup (e.g. minting auth keys). Use it _in addition to_ `convex dev --once` when |
| 113 | present — `predev` handles the one-time setup, `convex dev --once` pushes and |
| 114 | validates the code. |
| 115 | |
| 116 | ### Start the dev loop |
| 117 | |
| 118 | In most Convex templates, `npm run dev` runs both the Convex watcher and the |
| 119 | frontend dev server together (typically `convex dev --start 'vite --open'` or |
| 120 | the Next.js equivalent). That is what the user should run. |
| 121 | |
| 122 | ```bash |
| 123 | npm run dev |
| 124 | ``` |
| 125 | |
| 126 | If the project does not have a combined `dev` script — e.g. the `bare` template, |
| 127 | or an existing app where you haven't wired the frontend dev server into Convex's |
| 128 | `--start` flag — the user can run the Convex watcher directly: |
| 129 | |
| 130 | ```bash |
| 131 | npx convex dev |
| 132 | ``` |
| 133 | |
| 134 | `npx convex dev` is the same long-running watcher `npm run dev |