Create a static data router 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 data router for
The static handler context returned from staticHandler.query()
Future flags for the static data router
A static data router that can be used to render the provided routes