remix-run/react-router · warning

⚠️ Skipping prerendering for resource route without a loader

Error message

⚠️ Skipping prerendering for resource route without a loader: ${leafRoute.id}

What it means

During `react-router build` with prerendering enabled, resource routes are only prerendered when their leaf route exports a `loader`: a resource route with no loader has nothing to render or fetch, so both the .data file and the raw file requests are skipped and the Vite logger emits this warning naming the skipped route id. The build continues; only that route's prerendered output is missing.

Source

Thrown at packages/react-router-dev/vite/plugin.ts:2515

              manifestRoute &&
              !manifestRoute.hasDefaultExport &&
              !manifestRoute.hasErrorBoundary;

            if (isResourceRoute) {
              if (manifestRoute?.hasLoader) {
                requests.push(
                  // Prerender a .data file for turbo-stream consumption
                  createDataRequest(
                    prerenderPath,
                    reactRouterConfig,
                    [leafRoute.id],
                    true,
                  ),
                  // Prerender a raw file for external consumption
                  createResourceRouteRequest(prerenderPath, reactRouterConfig),
                );
              } else {
                viteConfig.logger.warn(
                  `⚠️ Skipping prerendering for resource route without a loader: ${leafRoute.id}`,
                );
              }
            } else {
              let hasLoaders = matches.some(
                (m) => reactRouterManifest.routes[m.route.id]?.hasLoader,
              );

              if (hasLoaders) {
                requests.push(
                  createDataRequest(prerenderPath, reactRouterConfig, null),
                );
              } else {
                requests.push(
                  createRouteRequest(prerenderPath, reactRouterConfig),
                );
              }
            }

View on GitHub (pinned to 6beaca3952)

Solutions

  1. Add a `loader` export to the resource route if it should emit prerendered .data/raw files — the loader's return value becomes the prerendered payload
  2. If the route is intentionally loader-less (static file semantics), remove its path from the `prerender` config to silence the warning
  3. Cross-check the route id in the warning against your routes to make sure the prerender entry points at the route you intended (typos and renames often map to the wrong leaf)

Example fix

// before - app/routes/resource.ts (no loader)
export function headers() { return { "Cache-Control": "public" }; }

// after
export async function loader() {
  return json({ generatedAt: Date.now() });
}
export function headers() { return { "Cache-Control": "public" }; }
Defensive patterns

Strategy: validation

Validate before calling

// before building with prerender, confirm covered resource routes export a loader
import glob from "fast-glob";
let files = await glob("app/routes/**/*.{ts,tsx}");
let loaderless = files.filter((f) => !/export\s+(async\s+)?function\s+loader|export\s+const\s+loader/.test(fs.readFileSync(f, "utf8")));
// cross-reference loaderless routes against your prerender path list before running `react-router build`

Type guard

// narrow a route module to "prerenderable resource route"
type ResourceRouteModule = { loader: Function };
function isResourceRouteWithLoader(mod: unknown): mod is ResourceRouteModule {
  return typeof (mod as ResourceRouteModule | undefined)?.loader === "function";
}

Prevention

When it happens

Trigger: `prerender: true` or a prerender path list that matches a resource route whose module has no `loader` export (e.g., it only exports headers/builder functions, or was emptied out).

Common situations: Converting a UI route into a resource route and deleting the loader while it's still covered by the prerender config; copy-paste prerender paths pointing at the wrong route; a route that only has a clientLoader; file renames leaving stale route ids.

Related errors


AI-assisted analysis of remix-run/react-router@6beaca3952 (2026-08-18). Data as JSON: /api/errors/722c5203f69d2cee. Report an issue: GitHub.