react-router.config.ts
Configures React Router application settings. Located atreact-router.config.ts in your project root.
Import
ReactRouterConfig Type
Configuration Options
appDirectory
string
default:"app"
Path to the application directory, relative to project root.
basename
string
default:"/"
Base path for all routes. Useful when your app is served from a subdirectory.
Must match Vite’s
base config:buildDirectory
string
default:"build"
Path to the build output directory, relative to project root.Output structure:
buildEnd
function
Hook called after build completes. Useful for custom post-build tasks.Example:
future
object
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
boolean | string[] | function | object
Defines which routes to prerender at build time as static HTML.Types:Examples:
presets
Preset[]
Configuration presets for platform integrations.Example:
routeDiscovery
object
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
string
default:"index.js"
Filename for the server build output.Output:
build/server/server.jsserverBundles
function
Split server code into multiple bundles based on route.Example:Outputs:
serverModuleFormat
'esm' | 'cjs'
default:"esm"
Module format for server build output.
Most modern runtimes support ESM. Use CJS only if required by your deployment platform.
ssr
boolean
default:"true"
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
string[]
Whitelist of allowed origins for form submissions. Supports glob patterns.Runtime Override:
Does not apply to resource routes (routes without UI components).