The fastest way to get started with TanStack Router is to scaffold a new project. Just run:
npx create-tsrouter-app@latestpnpx create-tsrouter-app@latestyarn dlx create-tsrouter-app@latestbunx create-tsrouter-app@latestThe CLI will guide you through a short series of prompts to customize your setup, including options for:
Once complete, a new project will be generated with TanStack Router installed and ready to use.
For full details on available options and templates, visit the create-tsrouter-app documentation.
TanStack Router supports both file-based and code-based route configurations. You can specify your preference during the CLI setup, or use these commands directly:
The file-based approach is the recommended option for most projects. It automatically creates routes based on your file structure, giving you the best mix of performance, simplicity, and developer experience.
npx create-tsrouter-app@latest my-app --template file-routerpnpx create-tsrouter-app@latest my-app --template file-routeryarn dlx create-tsrouter-app@latest my-app --template file-routerbunx create-tsrouter-app@latest my-app --template file-routerIf you prefer to define routes programmatically, you can use the code-based route configuration. This approach gives you full control over routing logic.
npx create-tsrouter-app@latest my-apppnpx create-tsrouter-app@latest my-appyarn dlx create-tsrouter-app@latest my-appbunx create-tsrouter-app@latest my-appWith either approach, navigate to your project directory and start the development server.
If you have an existing React project and want to add TanStack Router to it, you can install it manually.
Before installing TanStack Router, please ensure your project meets the following requirements:
Using TypeScript (v5.3.x or higher) is recommended for the best development experience, though not strictly required. We aim to support the last 5 minor versions of TypeScript, but using the latest version will help avoid potential issues.
TanStack Router is currently only compatible with React (with ReactDOM) and Solid. If you're interested in contributing to support other frameworks, such as React Native, Angular, or Vue, please reach out to us on Discord.
To install TanStack Router in your project, run the following command using your preferred package manager:
npm i @tanstack/react-routerpnpm add @tanstack/react-routeryarn add @tanstack/react-routerbun add @tanstack/react-routerOnce installed, you can verify the installation by checking your package.json file for the dependency.
{
"dependencies": {
"@tanstack/react-router": "^x.x.x"
}
}