Installation
Install the universal plugin package:Webpack Plugin
Basic Setup
Add the plugin to yourwebpack.config.js:
Configuration
Pass configuration options to the plugin:Specialized Webpack Plugins
Use separate plugins for generation and code splitting:With React
ESBuild Plugin
Basic Setup
Add the plugin to your ESBuild configuration:Configuration
Specialized ESBuild Plugins
With React and JSX
Rspack Plugin
Basic Setup
Add the plugin to your Rspack configuration:Configuration
Specialized Rspack Plugins
Configuration Options
All bundler plugins support the same configuration options:'react' | 'solid' | 'vue'
default:"react"
The framework you’re using with TanStack Router
string
default:"./src/routes"
The directory containing your route files
string
default:"./src/routeTree.gen.ts"
Where to output the generated route tree file
string
Optional prefix for route files
string
default:"-"
Files starting with this prefix will be ignored
'single' | 'double'
default:"single"
Quote style for generated code
boolean
default:false
Whether to include semicolons in generated code
boolean
Automatically enable code splitting for routes
boolean
default:false
Disable TypeScript type generation
boolean
default:false
Disable plugin logging output
CodeSplittingOptions
Advanced code splitting configuration:
Code Splitting
All plugins support automatic code splitting:TypeScript Support
All plugins generate TypeScript types automatically. Ensure yourtsconfig.json includes the generated files:
Validation with Zod
The plugins use Zod for configuration validation:Using Unplugin Directly
The plugins are built with unplugin, which provides a unified plugin interface. You can use the raw unplugin factories:Comparison with CLI
Bundler plugins vs CLI (tsr watch):
Recommendation: Use bundler plugins for better integration and features. Use CLI only if your bundler is not supported.
Comparison with Vite Plugin
The Vite plugin is the recommended choice for Vite projects:Troubleshooting
Plugin not working
- Verify the plugin is properly imported for your bundler
- Check that configuration options are valid
- Ensure route files exist in the configured directory
- Check bundler logs for errors
Routes not generating
- Verify
routesDirectorypath is correct - Check file naming conventions match expected patterns
- Ensure bundler is running in watch/dev mode
- Check for configuration validation errors
Type errors
- Include generated route tree in
tsconfig.json - Restart your TypeScript server
- Verify
disableTypesis not set totrue - Check that route files have valid TypeScript
Code splitting not working
- Set
autoCodeSplitting: true - Verify
codeSplittingOptionsconfiguration is valid - Check that route components are properly exported
- Ensure bundler supports dynamic imports
Webpack-specific issues
- Check React Refresh plugin order
- Verify babel configuration includes JSX transform
- Ensure source maps are enabled for debugging
ESBuild-specific issues
- Configure JSX transform:
jsx: 'automatic' - Set correct loaders for
.tsxand.tsfiles - ESBuild plugin support is limited - consider Vite
Rspack-specific issues
- Use within
tools.rspack.pluginsarray - Ensure Rsbuild React plugin is configured
- Check Rspack version compatibility (>= 1.0.2)