# React Router

React Router scores 15 of 28 points on 14 speed features: 8/14 on first-paint levers and 7/14 on other features. Rank 14 of 23, tied with SolidStart, Void (React), Void (Vue), Void (Solid). Labels: 5 1st-party, 1 Experimental, 4 Third-party, 4 Manual.

- Version checked: react-router / @react-router/dev 8.5.1 (the port's locked version; npm latest is 8.5.2, a patch release of 2026-11-18) (Framework mode is the Remix successor, formerly "React Router v7"; reactrouter.com docs now default to v8 (7.18.x still maintained).)
- Performance guide: [Automatic Code Splitting  | React Router](https://reactrouter.com/explanation/code-splitting)
- Issue tracker: https://github.com/remix-run/react-router/issues
- Books demo port: [react-router-books](https://github.com/MaxwellCohen/react-router-books)

## Summary

| Feature | Group | Label | Points |
| --- | --- | --- | --- |
| [Production CSS inlining](https://framework-compare.vercel.app/features/css-inlining.md) | First-paint levers | Manual | 0 |
| [Font optimization](https://framework-compare.vercel.app/features/font-optimization.md) | First-paint levers | Third-party | 1 |
| [Image pipeline](https://framework-compare.vercel.app/features/image-pipeline.md) | First-paint levers | Third-party | 1 |
| [Data/HTML caching](https://framework-compare.vercel.app/features/caching.md) | First-paint levers | 1st-party | 2 |
| [Route prefetching](https://framework-compare.vercel.app/features/route-prefetching.md) | First-paint levers | 1st-party | 2 |
| [Streaming SSR](https://framework-compare.vercel.app/features/streaming-ssr.md) | First-paint levers | 1st-party | 2 |
| [Early Hints / preload headers](https://framework-compare.vercel.app/features/early-hints.md) | First-paint levers | Manual | 0 |
| [Islands / partial hydration / lazy slices](https://framework-compare.vercel.app/features/islands.md) | Other features | Experimental | 1 |
| [Per-route render modes](https://framework-compare.vercel.app/features/render-modes.md) | Other features | 1st-party | 2 |
| [Fine-grained client reactivity](https://framework-compare.vercel.app/features/reactivity.md) | Other features | 1st-party | 2 |
| [Built-in bundle analysis](https://framework-compare.vercel.app/features/bundle-analysis.md) | Other features | Third-party | 1 |
| [Third-party script strategies](https://framework-compare.vercel.app/features/third-party-scripts.md) | Other features | Manual | 0 |
| [Portable multi-host deployment](https://framework-compare.vercel.app/features/multi-host-deployment.md) | Other features | Third-party | 1 |
| [Service worker / offline support](https://framework-compare.vercel.app/features/service-worker.md) | Other features | Manual | 0 |

## First-paint levers

### Production CSS inlining

Label: **Manual** (0 of 2 points).

No first-party CSS inlining documented; CSS is Vite's story (side-effect imports, `links` export with `?url`, React 19 `<link precedence>`). Inline by hand, e.g. `?inline`. ([styling](https://reactrouter.com/explanation/styling))

Example of building it yourself:

Import the stylesheet with Vite's `?inline` query instead of the port's `?url`, and render it in a `<style>` in the root `Layout`. The string also ships in the client bundle, so keep it small.

```tsx
// app/root.tsx
import appCss from './styles/global.css?inline'
// …
export const links: Route.LinksFunction = () => [
  { rel: 'icon', href: '/icon.svg', type: 'image/svg+xml' },
  // no { rel: 'stylesheet' } entry: the CSS is inlined below
]

export function Layout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <head>
        <Meta />
        <Links />
        <style dangerouslySetInnerHTML={{ __html: appCss }} />
      </head>
      {/* … */}
    </html>
  )
}
```

Source: [Vite: disabling CSS injection](https://vite.dev/guide/features.html#disabling-css-injection-into-the-page)

### Font optimization

Label: **Third-party** (1 of 2 points).

No first-party font primitive documented; the styling page does not cover fonts (use Fontsource or a CDN by hand). ([styling](https://reactrouter.com/explanation/styling))

Example of building it yourself:

The port installs Fontsource's variable Geist packages and imports them at the top of the global stylesheet. The packages ship the `@font-face` rules and self-hosted font files, and Vite bundles them like any other CSS import.

```css
/* app/styles/global.css */
@import '@fontsource-variable/geist';
@import '@fontsource-variable/geist-mono';
@import 'tailwindcss';

@theme {
  /* … */
  --font-geist-sans: 'Geist Variable', 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-geist-mono: 'Geist Mono Variable', 'Geist Mono', ui-monospace, monospace;
  --font-sans: var(--font-geist-sans);
  --font-mono: var(--font-geist-mono);
}
```

Source: [Fontsource: Installing fonts](https://fontsource.org/docs/getting-started/install)

### Image pipeline

Label: **Third-party** (1 of 2 points).

No first-party image component or optimizer documented (only a `?url` asset import is shown); use a community package such as `@unpic/react` or a host image CDN by hand. ([styling](https://reactrouter.com/explanation/styling))

Example of building it yourself:

Install `@unpic/react` and render its `<Image>` in place of `<img>`. When it recognizes the image CDN in the URL, it writes a responsive `srcset` that asks the CDN for each width. It also sets `sizes`, dimensions and lazy loading.

```tsx
// app/features/book/components/book-cover.tsx
import { Image } from '@unpic/react'

export function BookCover({ src, title }: { src: string; title: string }) {
  return (
    <Image
      src={src}
      layout="constrained"
      width={300}
      height={450}
      alt={title}
    />
  )
}
```

Source: [Unpic: @unpic/react](https://unpic.pics/img/react/)

Art direction with `<picture>` (Manual, not scored):

No first-party `<picture>` helper documented; hand-write the markup. ([styling](https://reactrouter.com/explanation/styling))

There is no image component, so write `<picture>` in a route or component, with files served from `public/`. React spells the attribute `srcSet`.

```tsx
// app/features/home/hero-image.tsx
export function HeroImage() {
  return (
    <picture>
      {/* art direction: a square crop on narrow screens */}
      <source media="(max-width: 640px)" type="image/avif"
              srcSet="/media/hero-square-640.avif" width={640} height={640} />
      {/* format fallback: AVIF, then WebP, then the <img> JPEG */}
      <source type="image/avif" sizes="100vw"
              srcSet="/media/hero-1280.avif 1280w, /media/hero-1920.avif 1920w" />
      <source type="image/webp" sizes="100vw"
              srcSet="/media/hero-1280.webp 1280w, /media/hero-1920.webp 1920w" />
      <img src="/media/hero-1280.jpg" alt="Shelves of books" width={1280} height={720}
           fetchPriority="high" decoding="async" />
    </picture>
  )
}
```

Source: [MDN: the picture element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/picture)

### Data/HTML caching

Label: **1st-party** (2 of 2 points).

Route `headers` export sets `Cache-Control` (deepest route wins; `parentHeaders` merges). `prerender` config is build-time only, with no ISR/revalidate option. Vercel's docs show `s-maxage=1, stale-while-revalidate=59` via `headers`. ([headers](https://reactrouter.com/how-to/headers), [pre-rendering](https://reactrouter.com/how-to/pre-rendering), [react-router](https://vercel.com/docs/frameworks/frontend/react-router))

Example of building it yourself:

Export `headers` from a route module to set `Cache-Control` on that route's document response. A child route can read `parentHeaders` and overwrite one value.

```tsx
// app/routes/book.tsx
import type { Route } from './+types/book'

export function headers({ parentHeaders }: Route.HeadersArgs) {
  parentHeaders.set(
    'Cache-Control',
    'max-age=3600, s-maxage=86400',
  )
  return parentHeaders
}
```

Source: [React Router: HTTP Headers](https://reactrouter.com/how-to/headers)

Gotchas:

- `headers` cannot see the response status; force `no-store` for 4xx/5xx in `entry.server` (`handleRequest` / `handleDataRequest`), or the CDN keeps error pages.

### Route prefetching

Label: **1st-party** (2 of 2 points).

`<Link prefetch="none|intent|render|viewport">`, default `none`, uses `<link rel="prefetch">`. Lazy route discovery is on by default and batch-discovers rendered links; `discover="none"` opts out. ([Link](https://reactrouter.com/api/components/Link), [lazy-route-discovery](https://reactrouter.com/explanation/lazy-route-discovery), [react-router.config.ts](https://reactrouter.com/api/framework-conventions/react-router.config.ts))

Example of building it yourself:

Set `prefetch` on `<Link>`. `"intent"` loads the route module and data on hover or focus, `"viewport"` when the link scrolls into view, and `"render"` as soon as it renders. The port wraps `<Link>` in its own `FastLink`.

```tsx
// app/components/ui/fast-link.tsx
import { Link } from 'react-router'
// …
export function FastLink({ href, prefetch = 'intent', ...rest }: Props) {
  return (
    <Link
      prefetch={prefetch === false ? 'none' : prefetch === true ? 'intent' : prefetch}
      to={href}
      {...rest}
    />
  )
}
```

Source: [React Router: Link](https://reactrouter.com/api/components/Link)

### Streaming SSR

Label: **1st-party** (2 of 2 points).

Return a promise from a `loader` without awaiting it, then render it with `<Await resolve={...}>` inside `<Suspense>`; the awaited data renders first and the rest streams in. The loader must return an object with keys, not a single promise. ([suspense](https://reactrouter.com/how-to/suspense))

Example of building it yourself:

The loader awaits the critical data and returns the slow promise as-is. The component renders that promise with `<Await>` inside `<Suspense>`, so the fallback goes out first.

```tsx
// app/routes/book.tsx
import { Suspense } from 'react'
import { Await } from 'react-router'
import type { Route } from './+types/book'

export async function loader({ params }: Route.LoaderArgs) {
  const reviews = getReviews(params.id) // NOT awaited
  const book = await getBook(params.id)
  return { book, reviews }
}

export default function Book({ loaderData }: Route.ComponentProps) {
  return (
    <>
      <h1>{loaderData.book.title}</h1>
      <Suspense fallback={<p>Loading reviews…</p>}>
        <Await resolve={loaderData.reviews}>
          {(reviews) => <ul>{reviews.map((r) => <li key={r.id}>{r.text}</li>)}</ul>}
        </Await>
      </Suspense>
    </>
  )
}
```

Source: [React Router: Streaming with Suspense](https://reactrouter.com/how-to/suspense)

### Early Hints / preload headers

Label: **Manual** (0 of 2 points).

No first-party preload `Link` headers or 103 Early Hints documented. The route `headers` export can set a `Link` header by hand, with the asset URLs listed by the app. ([headers](https://reactrouter.com/how-to/headers))

Example of building it yourself:

Export `headers` from a route module and return a `Link` header. This one preconnects to the font host. To preload a built file with a hashed name, read its URL from the Vite manifest.

```tsx
// app/routes/home.tsx
export function headers() {
  return { Link: '<https://fonts.gstatic.com>; rel=preconnect; crossorigin' };
}
```

Source: [React Router: HTTP headers](https://reactrouter.com/how-to/headers)

## Other features

### Islands / partial hydration / lazy slices

Label: **Experimental** (1 of 2 points).

Experimental RSC (React 19+): `unstable_reactRouterRSC` from `@react-router/dev/vite` plus experimental `@vitejs/plugin-rsc`; `unstable_`-prefixed and still unstable in 8.5.2. No islands or partial-hydration primitive documented. `splitRouteModules` only splits client exports. ([react-server-components](https://reactrouter.com/how-to/react-server-components), [code-splitting](https://reactrouter.com/explanation/code-splitting))

Example of building it yourself:

Swap `reactRouter()` for the unstable RSC plugin and add `@vitejs/plugin-rsc` after it. Route modules then render as React Server Components, and only `'use client'` modules ship JavaScript.

```ts
// vite.config.ts
import { defineConfig } from 'vite'
import { unstable_reactRouterRSC as reactRouterRSC } from '@react-router/dev/vite'
import rsc from '@vitejs/plugin-rsc'

export default defineConfig({
  plugins: [reactRouterRSC(), rsc()],
})
```

Source: [React Router: React Server Components](https://reactrouter.com/how-to/react-server-components)

### Per-route render modes

Label: **1st-party** (2 of 2 points).

`prerender` (stable config) takes a per-URL list, so listed paths are static while the rest are server-rendered (`ssr: true`) or served from the SPA fallback (`ssr: false`); `clientLoader` skips server data per route. `ssr` itself is global, with no per-route export; `ssr: "unstable_api-only"` is experimental (v8.5.0). ([rendering](https://reactrouter.com/start/framework/rendering), [pre-rendering](https://reactrouter.com/how-to/pre-rendering), [spa](https://reactrouter.com/how-to/spa))

Example of building it yourself:

List the URLs to prerender at build time. Those paths become static HTML, and every other path is server-rendered because `ssr` stays `true`.

```ts
// react-router.config.ts
import type { Config } from '@react-router/dev/config'

export default {
  // Can be omitted - defaults to true
  ssr: true,
  prerender: ['/', '/blog', '/blog/popular-post'],
} satisfies Config
```

Source: [React Router: Pre-Rendering](https://reactrouter.com/how-to/pre-rendering)

### Fine-grained client reactivity

Label: **1st-party** (2 of 2 points).

React-based; the first-party [React Compiler](https://react.dev/learn/react-compiler) is added as a Babel preset to the React Vite plugin (not enabled in this port). v8.4.0 also split internal router contexts to reduce router re-renders. ([react-compiler](https://react.dev/learn/react-compiler), [changelog](https://reactrouter.com/changelog))

Example of building it yourself:

Add the React Compiler's Babel plugin next to `reactRouter()`. The compiler memoizes components and hooks at build time, so fewer components re-render when state changes.

```ts
// vite.config.ts
import { defineConfig } from 'vite'
import babel from 'vite-plugin-babel'
import { reactRouter } from '@react-router/dev/vite'

export default defineConfig({
  plugins: [
    reactRouter(),
    babel({
      filter: /\.[jt]sx?$/,
      babelConfig: {
        presets: ['@babel/preset-typescript'],
        plugins: [['babel-plugin-react-compiler', {}]],
      },
    }),
  ],
})
```

Source: [React: React Compiler installation](https://react.dev/learn/react-compiler/installation)

Gotchas:

- The React Compiler is opt-in: add its Babel preset to the React Vite plugin.

### Built-in bundle analysis

Label: **Third-party** (1 of 2 points).

No first-party analyzer documented; the code-splitting page does not mention one; the third-party route is a community Vite/Rollup visualizer such as [rollup-plugin-visualizer](https://github.com/btd/rollup-plugin-visualizer), added by hand. No React Router page recommends one. ([code-splitting](https://reactrouter.com/explanation/code-splitting))

Example of building it yourself:

Add `rollup-plugin-visualizer` to the Vite config. `react-router build` then writes a treemap of the client bundle to `stats.html`.

```ts
// vite.config.ts
import { reactRouter } from '@react-router/dev/vite'
import tailwindcss from '@tailwindcss/vite'
import { visualizer } from 'rollup-plugin-visualizer'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    tailwindcss(),
    reactRouter(),
    visualizer({ filename: 'stats.html', gzipSize: true }),
  ],
})
```

Source: [rollup-plugin-visualizer: README](https://github.com/btd/rollup-plugin-visualizer)

### Third-party script strategies

Label: **Manual** (0 of 2 points).

No first-party strategy documented; `<Scripts>` renders the app runtime and only spreads attributes (`crossOrigin`, `nonce`), with no `async`/`defer` strategy documented. ([Scripts](https://reactrouter.com/api/components/Scripts))

Example of building it yourself:

`<Scripts />` only renders the app runtime, so write the tags yourself: `async` in `Layout` for early scripts, or inject in a `useEffect` after hydration.

```tsx
// app/root.tsx
import { useEffect } from 'react'
// …
export function Layout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <head>
        {/* … */}
        {/* React 19 hoists and de-duplicates <script async src> */}
        <script async src="https://plausible.io/js/script.js" data-domain="books.example" />
      </head>
      {/* … */}
    </html>
  )
}

export default function App() {
  useEffect(() => {
    // Client only, after hydration: load the chat widget when the browser is idle.
    ;(window.requestIdleCallback ?? setTimeout)(() => {
      const s = document.createElement('script')
      s.src = 'https://widget.example.com/chat.js'
      s.async = true
      document.body.append(s)
    })
  }, [])
  // …
}
```

Source: [React: the script component](https://react.dev/reference/react-dom/components/script)

### Portable multi-host deployment

Label: **Third-party** (1 of 2 points).

React Router-maintained adapters: `@react-router/serve` and `@react-router/express` (Node), `@react-router/cloudflare`, and `@react-router/architect` (AWS); v8 removed the Cloudflare dev proxy in favor of `@cloudflare/vite-plugin`. Vercel (`@vercel/react-router` preset) and Netlify (`@netlify/vite-plugin-react-router`) are host-maintained, not React Router-owned, so two of the four hosts this repo targets rely on host packages. ([adapter](https://reactrouter.com/api/other-api/adapter), [deploying](https://reactrouter.com/start/framework/deploying), [react-router](https://vercel.com/docs/frameworks/frontend/react-router), [react-router](https://docs.netlify.com/build/frameworks/framework-setup-guides/react-router/), [react-router](https://developers.cloudflare.com/workers/framework-guides/web-apps/react-router/))

Example of building it yourself:

The port picks a host plugin from environment variables at build time. Cloudflare uses `@cloudflare/vite-plugin`, Netlify uses its own React Router plugin, and Vercel uses the `vercelPreset()` in `react-router.config.ts`.

```ts
// vite.config.ts
import { reactRouter } from '@react-router/dev/vite'
import { cloudflare } from '@cloudflare/vite-plugin'
import netlifyReactRouter from '@netlify/vite-plugin-react-router'
import { defineConfig, type PluginOption } from 'vite'

const env = process.env
const isCloudflare = !!(env.CLOUDFLARE || env.WORKERS_CI || env.CF_PAGES)
const isNetlify = !!env.NETLIFY && !isCloudflare

const hostPlugins: PluginOption[] = isCloudflare
  ? [cloudflare({ viteEnvironment: { name: 'ssr' } })]
  : isNetlify
    ? [netlifyReactRouter()]
    : []

export default defineConfig({
  plugins: [...hostPlugins, reactRouter()],
})
```

Source: [React Router: Deploying](https://reactrouter.com/start/framework/deploying)

### Service worker / offline support

Label: **Manual** (0 of 2 points).

No service worker support documented. The community `@vite-pwa/remix` package (0.2.0, published 2025-03-30) targets Remix and does not state React Router v8 support, so it is not credited. Hand-write the worker in `public/` and register it. ([vite-pwa remix](https://vite-pwa-org.netlify.app/frameworks/remix))

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script in the root route.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// app/root.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// … in <head>
        <script dangerouslySetInnerHTML={{ __html: swScript }} />
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers)

## Other performance features

- Lazy route discovery by default. ([lazy-route-discovery](https://reactrouter.com/explanation/lazy-route-discovery))
- `splitRouteModules` on by default in v8.0.0; `"enforce"` available. Server-only exports (`loader`, `action`, `headers`) are removed from browser bundles. ([code-splitting](https://reactrouter.com/explanation/code-splitting))
- Web Streams server entry by default for non-Node apps (v8.2.0); `ssr: "unstable_api-only"` (Framework mode, v8.5.0) is experimental, as is `future.unstable_routePatternMatching` (v8.4.0), which is a Data Mode flag passed to `createBrowserRouter`, not a `react-router.config.ts` option. ([changelog](https://reactrouter.com/changelog))

## Deployments of the Books demo

| Branch | Note | Vercel | Netlify | Cloudflare |
| --- | --- | --- | --- | --- |
| `main` | vibe port | https://react-router-books-tau.vercel.app | https://react-router-books.netlify.app | https://react-router-books.to-email-max.workers.dev |
| `optimized` | cache + fonts | https://react-router-books-optimized.vercel.app | https://react-router-books-max-optimized.netlify.app | https://react-router-books-optimized.to-email-max.workers.dev |

## Benchmark, 2026-11-28

Tool: PageSpeed Insights v5 (Lighthouse lab run), mobile strategy. 3 measured runs per deployment, median reported; cold runs are left out of the median when a warm run exists. Each build's figure is the average of its hosts' medians (vercel, netlify, cloudflare). Pages measured: book list (/) and one book (/10145787). Times are lab values from one run on 2026-11-28. FCP is the Lighthouse estimate for simulated Slow 4G; Raw FCP, where shown, is the first paint in the real, unthrottled load that estimate is built from. Builds in the same FCP band (https://framework-compare.vercel.app/measured.md) are a tie, so read "fastest first" as band order.

| Page | Build | Branch | Hosts | Performance | FCP | Raw FCP | LCP | TBT | CLS |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| book list (/) | baseline | `main` | cloudflare, netlify, vercel | 83 | 1.51 s | 0.64 s | 4.61 s | 5 ms | 0.001 |
| book list (/) | optimized | `optimized` | cloudflare, netlify, vercel | 85 | 0.91 s | 1.65 s | 4.21 s | 10 ms | 0.000 |
| one book (/10145787) | baseline | `main` | cloudflare, netlify, vercel | 94 | 1.52 s | 1.34 s | 2.97 s | 3 ms | 0.000 |
| one book (/10145787) | optimized | `optimized` | cloudflare, netlify, vercel | 97 | 0.91 s | 0.96 s | 2.52 s | 5 ms | 0.000 |

Full run: https://framework-compare.vercel.app/benchmark.md

---

HTML version: https://framework-compare.vercel.app/frameworks/react-router · All pages: https://framework-compare.vercel.app/llms.txt · Data: https://framework-compare.vercel.app/api/index.json
