Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tanstack create [project-name] [options]
| `--package-manager <pm>` | `npm`, `pnpm`, `yarn`, `bun`, `deno` |
| `--framework <name>` | `React`, `Solid` |
| `--router-only` | Create file-based Router-only app without TanStack Start (add-ons/deployment/template disabled) |
| `--router-and-start` | Use TanStack Start explicitly (skips the interactive router-only prompt) |
| `--toolchain <id>` | Toolchain add-on (use `--list-add-ons` to see options) |
| `--deployment <id>` | Deployment add-on (use `--list-add-ons` to see options) |
| `--examples` / `--no-examples` | Include or exclude demo/example pages |
Expand Down
28 changes: 28 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function getCreateTelemetryProperties(projectName: string, options: CliOptions)
package_manager: options.packageManager,
project_name_provided: Boolean(projectName),
router_only: !!options.routerOnly,
router_and_start: !!options.routerAndStart,
target_dir_flag: Boolean(options.targetDir),
toolchain:
typeof options.toolchain === 'string' ? sanitizeId(options.toolchain) : undefined,
Expand Down Expand Up @@ -229,6 +230,7 @@ function getResolvedCreateTelemetryProperties(
intent: finalOptions.intent,
package_manager: finalOptions.packageManager,
router_only: !!cliOptions.routerOnly,
router_and_start: !!cliOptions.routerAndStart,
toolchain: toolchain ? sanitizeId(toolchain.id) : undefined,
}
}
Expand Down Expand Up @@ -810,6 +812,28 @@ export function cli({
...options,
} as CliOptions

if (cliOptions.routerAndStart) {
if (cliOptions.routerOnly) {
throw new Error(
'Cannot combine --router-only with --router-and-start.',
)
}
if (
cliOptions.template &&
['typescript', 'tsx', 'javascript', 'js', 'jsx'].includes(
cliOptions.template.toLowerCase(),
)
) {
console.warn(
chalk.yellow(
'Ignoring --template in favor of --router-and-start (TanStack Start).',
),
)
cliOptions.template = undefined
}
cliOptions.routerOnly = false
}

if (defaultRouterOnly && cliOptions.routerOnly === undefined) {
cliOptions.routerOnly = true
}
Expand Down Expand Up @@ -992,6 +1016,10 @@ export function cli({
'--router-only',
'Use router-only compatibility mode (file-based routing without TanStack Start)',
)
.option(
'--router-and-start',
'Use TanStack Start explicitly (skips the interactive router-only prompt)',
)
.option(
'--blank',
'Create a minimal one-route app without default starter UI, Tailwind, devtools, or tests',
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
selectGit,
selectInstall,
selectPackageManager,
selectRouterOnly,
selectTemplate,
selectToolchain,
} from './ui-prompts.js'
Expand Down Expand Up @@ -95,9 +96,17 @@ export async function promptForCreateOptions(
['file-router', 'typescript', 'tsx', 'javascript', 'js', 'jsx'].includes(
template,
)
const hasTemplateIntent = !!cliOptions.template || !!cliOptions.starter
const routerOnly =
!!cliOptions.routerOnly ||
(isLegacyTemplate ? template !== 'file-router' : false)
(isLegacyTemplate ? template !== 'file-router' : false) ||
(cliOptions.routerOnly === undefined &&
!isLegacyTemplate &&
!hasTemplateIntent &&
(await selectRouterOnly()))
if (routerOnly) {
cliOptions.routerOnly = true
}

if (!cliOptions.starter) {
if (cliOptions.template && !isLegacyTemplate) {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface CliOptions {
addOnConfig?: string
force?: boolean
routerOnly?: boolean
routerAndStart?: boolean
blank?: boolean
template?: string
tailwind?: boolean
Expand Down
12 changes: 12 additions & 0 deletions packages/cli/src/ui-prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ export async function selectFramework(
return framework
}

export async function selectRouterOnly(): Promise<boolean> {
const routerOnly = await confirm({
message: 'Use Tanstack Router without Start?',
initialValue: false,
})
if (isCancel(routerOnly)) {
cancel('Operation cancelled.')
process.exit(0)
}
return routerOnly
}

export async function selectInstall(): Promise<boolean> {
const install = await confirm({
message: 'Would you like to install dependencies now?',
Expand Down