Skip to content
Source
Sign inSign up
TanStack/cli
Open History to see the last commit

cli-reference.md

328 lines8.5 KB

1---
2id: cli-reference
3title: CLI Reference
4---
5​
6## tanstack create
7​
8Create a new TanStack application. By default creates a TanStack Start app with SSR.
9​
10```bash
11tanstack create [project-name] [options]
12```
13​
14| Option | Description |
15|--------|-------------|
16| `--add-ons <ids>` | Comma-separated add-on IDs |
17| `--template <url-or-id>` | Template URL/path or built-in template ID |
18| `--blank` | Create a minimal one-route Start project without default starter UI, examples, Tailwind, devtools, or a test stack |
19| `--package-manager <pm>` | `npm`, `pnpm`, `yarn`, `bun`, `deno` |
20| `--framework <name>` | `React`, `Solid` |
21| `--build-tool <name>` | `vite` (default), `rsbuild` |
22| `--router-only` | Create file-based Router-only app without TanStack Start (add-ons/deployment/template disabled) |
23| `--toolchain <id>` | Toolchain add-on (use `--list-add-ons` to see options) |
24| `--deployment <id>` | Deployment add-on (use `--list-add-ons` to see options) |
25| `--examples` / `--no-examples` | Include or exclude demo/example pages |
26| `--tailwind` / `--no-tailwind` | Deprecated compatibility flags for standard projects; blank projects omit Tailwind |
27| `--no-git` | Skip git init |
28| `--no-install` | Skip dependency install |
29| `-y, --yes` | Use defaults, skip prompts |
30| `--interactive` | Force interactive mode |
31| `--target-dir <path>` | Custom output directory |
32| `-f, --force` | Overwrite existing directory |
33| `--list-add-ons` | List all available add-ons |
34| `--addon-details <id>` | Show details for specific add-on |
35| `--json` | Output machine-readable JSON for automation |
36| `--add-on-config <json>` | JSON string with add-on options |
37​
38```bash
39# Examples
40tanstack create my-app -y
41tanstack create my-app --blank -y
42tanstack create my-app --blank --deployment cloudflare -y
43tanstack create my-app --add-ons clerk,drizzle,tanstack-query
44tanstack create my-app --router-only --toolchain eslint --no-examples
45tanstack create my-app --build-tool rsbuild -y
46tanstack create my-app --framework Solid --build-tool rsbuild --router-only --blank --toolchain biome -y
47tanstack create my-app --template https://example.com/template.json
48tanstack create my-app --template ecommerce
49tanstack create --list-add-ons --framework React --json
50tanstack create --addon-details drizzle --framework React --json
51```
52​
53`--blank` creates the smallest useful TanStack Start project: one route and no
54default starter interface, examples, Tailwind, devtools, test dependencies, or
55TanStack Intent setup. Pass `--intent` when the project should include local
56skill mappings for coding agents.
57Explicit add-ons and deployment adapters can add their own required files and
58dependencies. Add `-y` to use defaults for every remaining option; when the
59target is non-empty, also pass `--force` or the command exits without writing.
60​
61### Programmatic generation
62​
63Use `@tanstack/create/worker` in Cloudflare Workers and other edge SSR runtimes. It does not import the generated template manifest at module startup. Instead, provide a loader for the framework and add-on chunks your Worker supports.
64​
65The default `@tanstack/create` export is still the Node/CLI path and scans framework templates from disk. `@tanstack/create/edge` remains the bundled in-memory manifest path; it is Worker-compatible at runtime, but it imports the full generated manifest and is not appropriate for size-constrained Worker bundles.
66​
67```ts
68import {
69 createMemoryEnvironment,
70 createWorkerCreate,
71 createWorkerManifestLoader,
72} from '@tanstack/create/worker'
73import { manifestCatalog } from '@tanstack/create/worker-manifest/catalog'
74​
75import type {
76 WorkerAddOnManifestModule,
77 WorkerFrameworkManifestModule,
78} from '@tanstack/create/worker'
79​
80const frameworkLoaders: Record<
81 string,
82 () => Promise<WorkerFrameworkManifestModule>
83> = {
84 react: () => import('@tanstack/create/worker-manifest/frameworks/react'),
86​
87const addOnLoaders: Record<
88 string,
89 Record<string, () => Promise<WorkerAddOnManifestModule>>
90> = {
91 react: {
92 'tanstack-query': () =>
93 import(
94 '@tanstack/create/worker-manifest/frameworks/react/add-ons/tanstack-query'
95 ),
96 cloudflare: () =>
97 import(
98 '@tanstack/create/worker-manifest/frameworks/react/add-ons/cloudflare'
99 ),
100 },
102​
103const create = createWorkerCreate(
104 createWorkerManifestLoader({
105 loadCatalog: async () => manifestCatalog,
106 async loadFramework(frameworkId) {
107 const load = frameworkLoaders[frameworkId]
108 if (!load) throw new Error(`Unsupported framework: ${frameworkId}`)
109 return load()
110 },
111 async loadAddOn(frameworkId, addOnId) {
112 const load = addOnLoaders[frameworkId]?.[addOnId]
113 if (!load) throw new Error(`Unsupported add-on: ${addOnId}`)
114 return load()
115 },
116 }),
118​
119const framework = await create.getFrameworkById('react')
120const chosenAddOns = await create.finalizeAddOns(framework!, 'file-router', [
121 'tanstack-query',
122 'cloudflare',
123])
124const addOnOptions = create.populateAddOnOptionsDefaults(chosenAddOns)
125const { environment, output } = createMemoryEnvironment('/app')
126​
127await create.createApp(environment, {
128 projectName: 'app',
129 targetDir: '/app',
130 framework: framework!,
131 mode: 'file-router',
132 bundler: 'vite',
133 typescript: true,
134 tailwind: true,
135 packageManager: 'pnpm',
136 git: false,
137 install: false,
138 intent: false,
139 chosenAddOns,
140 addOnOptions,
141})
142​
143// output.files contains generated files for ZIP creation.
144```
145​
146---
147​
148## tanstack add
149​
150Add add-ons to an existing project.
151​
152```bash
153tanstack add [add-on...] [options]
154```
155​
156| Option | Description |
157|--------|-------------|
158| `--forced` | Force add-on installation even if conflicts exist |
159​
160```bash
161# Examples
162tanstack add clerk drizzle
163tanstack add tanstack-query,tanstack-form
164```
165​
166Visual setup is available at `https://tanstack.com/builder`.
167​
168---
169​
170## tanstack add-on
171​
172Create and manage custom add-ons.
173​
174### init
175​
176Extract add-on from current project:
177​
178```bash
179tanstack add-on init
180```
181​
182Creates `.add-on/` folder with `info.json` and `assets/`.
183​
184### compile
185​
186Rebuild after changes:
187​
188```bash
189tanstack add-on compile
190```
191​
192See [Creating Add-ons](./creating-add-ons.md) for full guide.
193​
194---
195​
196## tanstack template
197​
198Create reusable project templates.
199​
200### init
201​
202```bash
203tanstack template init
204```
205​
206Creates `template-info.json` and `template.json`.
207​
208### compile
209​
210```bash
211tanstack template compile
212```
213​
214See [Templates](./templates.md) for full guide.
215​
216## tanstack libraries
217​
218List TanStack libraries with optional group filtering.
219​
220```bash
221tanstack libraries [options]
222```
223​
224| Option | Description |
225|--------|-------------|
226| `--group <group>` | Filter by group: `state`, `headlessUI`, `performance`, `tooling` |
227| `--json` | Output machine-readable JSON |
228​
229```bash
230tanstack libraries
231tanstack libraries --group state --json
232```
233​
234---
235​
236## tanstack doc
237​
238Fetch a TanStack documentation page by library and path.
239​
240```bash
241tanstack doc <library> <path> [options]
242```
243​
244| Option | Description |
245|--------|-------------|
246| `--docs-version <version>` | Docs version (default: `latest`) |
247| `--json` | Output machine-readable JSON |
248​
249```bash
250tanstack doc router framework/react/guide/data-loading
251tanstack doc query framework/react/overview --docs-version v5 --json
252```
253​
254---
255​
256## tanstack search-docs
257​
258Search TanStack documentation.
259​
260```bash
261tanstack search-docs <query> [options]
262```
263​
264| Option | Description |
265|--------|-------------|
266| `--library <id>` | Filter by library ID |
267| `--framework <name>` | Filter by framework |
268| `--limit <n>` | Max results (default `10`, max `50`) |
269| `--json` | Output machine-readable JSON |
270​
271```bash
272tanstack search-docs "server functions" --library start
273tanstack search-docs loaders --library router --framework react --json
274```
275​
276---
277​
278## tanstack ecosystem
279​
280List ecosystem partner recommendations.
281​
282```bash
283tanstack ecosystem [options]
284```
285​
286| Option | Description |
287|--------|-------------|
288| `--category <category>` | Filter by category |
289| `--library <id>` | Filter by TanStack library |
290| `--json` | Output machine-readable JSON |
291​
292```bash
293tanstack ecosystem --category database
294tanstack ecosystem --library router --json
295```
296​
297---
298​
299## tanstack pin-versions
300​
301Pin TanStack package versions to avoid conflicts.
302​
303```bash
304tanstack pin-versions
305```
306​
307Removes `^` from version ranges for TanStack packages and adds any missing peer dependencies.
308​
309---
310​
311## Configuration
312​
313Projects include `.cta.json`:
314​
315```json
317 "version": 1,
318 "projectName": "my-app",
319 "framework": "react",
320 "mode": "file-router",
321 "typescript": true,
322 "tailwind": true,
323 "packageManager": "pnpm",
324 "chosenAddOns": ["tanstack-query", "clerk"]
326```
327​
328Used by `add-on init` and `template init` to detect changes.