interface RouterLoadContext
Since 0.2.0

The per-request context object React Router passes to loaders, actions, and middleware as context.

React Router 8 requires this to be a real RouterContextProvider instance — it performs a nominal instanceof check in createRequestHandler and again in the static handler whenever route middleware is used. A structurally equivalent object is therefore NOT sufficient, which is why the instance is always constructed by SsrRuntime.createLoadContext, sourced from the same react-router module the request handler came from.

Methods

get<T>(key: RouterContextKey<T>): T

Reads a key, falling back to the key's defaultValue.

set<T>(
value: T
): void

Writes a key, overwriting any previous value.

Usage

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