React Router API Reference
    Preparing search index...

    Function createStaticHandler

    • Create a static handler to perform server-side data loading

      Parameters

      • routes: RouteObject[]

        The route objects to create a static handler for

      • Optionalopts: CreateStaticHandlerOptions

        Options

        • basename

          The base URL for the static handler (default: /)

        • future

          Future flags for the static handler

      Returns StaticHandler

      A static handler that can be used to query data for the provided routes

      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

      data