react-router.config.ts
Configures React Router application settings. Located atreact-router.config.ts in your project root.
Import
ReactRouterConfig Type
Configuration Options
appDirectory
Path to the application directory, relative to project root.
basename
Base path for all routes. Useful when your app is served from a subdirectory.
Must match Vite’s
base config:buildDirectory
Path to the build output directory, relative to project root.Output structure:
buildEnd
Hook called after build completes. Useful for custom post-build tasks.Example:
future
Enables future features and breaking changes.Example:Flags:
unstable_optimizeDeps- Optimize dependency pre-bundlingunstable_subResourceIntegrity- Generate SRI hashes for scriptsunstable_trailingSlashAwareDataRequests- Handle trailing slashes in data requestsunstable_previewServerPrerendering- Prerender with Vite preview serverv8_middleware- Enable route middlewarev8_splitRouteModules- Automatic route code splitting (true|"enforce")v8_viteEnvironmentApi- Use Vite Environment API
prerender
Defines which routes to prerender at build time as static HTML.Types:Examples:
presets
Configuration presets for platform integrations.Example:
routeDiscovery
Controls lazy route discovery behavior.Default:
{ mode: "lazy", manifestPath: "/__manifest" } (when SSR enabled)Examples:Lazy mode requires SSR. With
ssr: false, mode is automatically "initial".serverBuildFile
Filename for the server build output.Output:
build/server/server.jsserverBundles
Split server code into multiple bundles based on route.Example:Outputs:
serverModuleFormat
Module format for server build output.
Most modern runtimes support ESM. Use CJS only if required by your deployment platform.
ssr
Enables server-side rendering. Set to SPA Mode:
false for SPA mode.- Pre-renders
/at build time - Saves as
index.html - No server required
- All routes client-side only
allowedActionOrigins
Whitelist of allowed origins for form submissions. Supports glob patterns.Runtime Override:
Does not apply to resource routes (routes without UI components).