function createLoadContextFactory
Since 0.2.0
createLoadContextFactory(rr: Record<string, unknown>): () => RouterLoadContext

Builds the per-request context factory from React Router's RouterContextProvider class.

React Router 8 checks initialContext instanceof RouterContextProvider and answers a 500 Unexpected Server Error when it fails, so the class itself — not a structural stand-in — has to reach the handler.

Extracted as a pure function so the branch is unit-testable without importing react-router.

Parameters

rr: Record<string, unknown>

The loaded react-router module namespace

Return Type

A factory constructing a fresh, empty provider per request

Throws

Error

When the module exposes no RouterContextProvider export

Usage

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