Props
The StaticHandlerContext returned from StaticHandler's
query
Optionalhydrate?: booleanWhether to hydrate the router on the client (default true)
Optionalnonce?: stringThe static DataRouter from createStaticRouter
A React element that renders the static router provider
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" } }
);
}
@public
A DataRouter that may not navigate to any other Location. This is useful on the server where there is no stateful UI.