remix-run/react-router · error

The `future.v8_middleware` flag has been removed because mid

Error message

The `future.v8_middleware` flag has been removed because middleware is now always enabled

What it means

Fatal config-validation error: readConfig aborts when `future` contains `unstable_middleware` or `v8_middleware`. Middleware (`context`, `next` route middlewares) is always enabled in this version, so the opt-in flag was removed. Any occurrence of the key — even `v8_middleware: false` — is treated as a stale v7 config and fails fast, which also protects you from assuming middleware could be turned off.

Source

Thrown at packages/react-router-dev/config/config.ts:727

      "v8_viteEnvironmentApi" in futureConfig
    ) {
      return err(
        "The `future.v8_viteEnvironmentApi` flag has been removed because Vite Environment API usage is now always enabled",
      );
    }
    if (
      "unstable_passThroughRequests" in futureConfig ||
      "v8_passThroughRequests" in futureConfig
    ) {
      return err(
        "The `future.v8_passThroughRequests` flag has been removed because pass-through requests are now the default behavior",
      );
    }
    if (
      "unstable_middleware" in futureConfig ||
      "v8_middleware" in futureConfig
    ) {
      return err(
        "The `future.v8_middleware` flag has been removed because middleware is now always enabled",
      );
    }
    if (
      "unstable_trailingSlashAwareDataRequests" in futureConfig ||
      "v8_trailingSlashAwareDataRequests" in futureConfig
    ) {
      return err(
        "The `future.v8_trailingSlashAwareDataRequests` flag has been removed because trailing slash-aware data requests are now the default behavior",
      );
    }
    if ("unstable_subResourceIntegrity" in futureConfig) {
      return err(
        "The `future.unstable_subResourceIntegrity` flag has been stabilized and moved to a top-level `config.subResourceIntegrity` field",
      );
    }
  }

View on GitHub (pinned to 6beaca3952)

Solutions

  1. Delete the `v8_middleware` / `unstable_middleware` key from `future` — middleware is always on
  2. If your app relied on `v8_middleware: false`, audit route modules: middleware-style exports now always run; remove or guard middleware files you don't want
  3. Re-run typegen and tests to confirm nothing assumed middleware was disabled
  4. Clean up the other removed v8_* flags in the same edit to avoid the sibling config errors

Example fix

// before - react-router.config.ts
export default {
  future: { v8_middleware: true },
} satisfies Config;

// after
export default {} satisfies Config; // middleware is always enabled
Defensive patterns

Strategy: validation

Validate before calling

import fs from "node:fs";
let cfg = fs.readFileSync("react-router.config.ts", "utf8");
if (/unstable_middleware|v8_middleware/.test(cfg)) {
  throw new Error("Remove `future.v8_middleware` — middleware is always enabled now");
}

Type guard

function isCurrentFutureConfig(f: unknown): boolean {
  return typeof f === "object" && f !== null &&
    !("v8_middleware" in f) && !("unstable_middleware" in f);
}

Try / catch

try {
  let result = await readConfig(root);
} catch (e) {
  if (e instanceof Error && e.message.includes("v8_middleware")) {
    // remove the key; then verify no code depended on middleware being off
  } else throw e;
}

Prevention

When it happens

Trigger: Running any command that loads the config (`react-router dev`/`build`/`typegen`) with `future.unstable_middleware` or `future.v8_middleware` present in react-router.config.ts or in merged preset/extends configs.

Common situations: v7 apps that enabled middleware early and are upgrading; teams that kept the flag at false to delay middleware and now must verify no code depends on it being off; copied configs from middleware tutorials.

Related errors


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