interface ReactRouterPluginOptions
Since 0.1.0

Options for the React Router plugin.

Properties

Since 0.1.0
readonly
serverBuildPath: string

Path to the React Router Vite server build (default export = ServerBuild).

Must be absolute — an absolute filesystem path or a file: URL. The default loader performs await import(serverBuildPath), and a relative specifier there resolves against this plugin's own module rather than against the consuming application, so it can never find the build. From an application module, derive one with new URL('./build/server/index.js', import.meta.url).href.

Since 0.2.0 Returns an {@linkcode SsrRuntime} rather than a bare handler,
readonly
optional
loadRequestHandler: (
serverBuildPath: string,
mode: string
) => Promise<SsrRuntime>

Injectable seam for lazy loading the RR runtime. When omitted, the default performs await import(serverBuildPath) + await import('npm:react-router@8').

Also the supported hook for a development server: return a handler built over a build thunk (createRequestHandler(() => vite.ssrLoadModule(...))) to pick up rebuilds without restarting the process.

Since 0.1.0
readonly
optional
assetsDir: string

Filesystem root of the built client bundle. Omit to disable static-asset serving (no asset route registered).

Since 0.1.0
readonly
optional
assetUrlPrefix: string

URL prefix for the static-asset route. Default /assets/.

Since 0.2.0
readonly
optional
publicFiles: boolean

Also serves files from the client-build ROOT — where Vite copies public/ (robots.txt, favicon.ico, …) — in addition to ReactRouterPluginOptions.assetUrlPrefix, with Cache-Control: public, max-age=0, must-revalidate: root files are not content-hashed, so they must be revalidated rather than cached immutably. A request matching neither the root nor the prefix still falls through to the SSR catch-all.

Default true. false preserves prefix-only serving exactly as before.

Since 0.1.0
readonly
optional
basename: string

Mount prefix for the SSR catch-all route. Default /. MUST match the app's react-router.config.ts basename for flat/nested routes to resolve.

Since 0.2.0
readonly
optional
populateLoadContext: PopulateLoadContext

Adds application values to the per-request React Router context, on top of the servicesContext and userContext keys the plugin always sets.

Replaces the removed getLoadContext option: React Router 8 requires a real RouterContextProvider instance, which an app-supplied function cannot safely construct, so the callback now mutates the provider the plugin built instead of returning a plain object.

Since 0.1.0
readonly
optional
mode: "production" | "development"

Mode passed to createRequestHandler(build, mode).

Usage

import { type ReactRouterPluginOptions } from "react-router-plugin/src/index.ts";