function loadRequestHandler
Since 0.1.0
loadRequestHandler(
serverBuildPath: string,
mode: string,
options?: { rrImportHook?: () => Promise<Record<string, unknown>>; }
): Promise<SsrRuntime>

Default implementation of loadRequestHandler.

Lazily imports the app-provided server build (import(serverBuildPath)) and the core react-router package (import('npm:react-router@8')), unwraps the ServerBuild (default export), then returns a callable request handler.

Both the handler and the context-provider factory come from the SAME module object, so the provider instance can never be tested against a different copy of the RouterContextProvider class than the one it was constructed from.

Parameters

serverBuildPath: string

Path to the RR Vite server build (app-provided)

mode: string

'production' or 'development'

optional
options: { rrImportHook?: () => Promise<Record<string, unknown>>; }

Optional override for the react-router import seam

Return Type

Promise<SsrRuntime>

A promise resolving to the handler and its context factory

Throws

Error

When either import fails, with a message naming the missing specifier

Usage

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