Create a static DataRouter
for server-side rendering
export async function handleRequest(request: Request) {
let { query, dataRoutes } = createStaticHandler(routes);
let context = await query(request);
if (context instanceof Response) {
return context;
}
let router = createStaticRouter(dataRoutes, context);
return new Response(
ReactDOMServer.renderToString(<StaticRouterProvider ... />),
{ headers: { "Content-Type": "text/html" } }
);
}
function createStaticRouter(
routes: RouteObject[],
context: StaticHandlerContext,
opts: {
future?: Partial<FutureConfig>;
} = ,
): DataRouter {}
The route objects to create a static DataRouter
for
The StaticHandlerContext
returned from StaticHandler
's query
Future flags for the static DataRouter
A static DataRouter
that can be used to render the provided routes