# Astro

Astro scores 24 of 28 points on 14 speed features: 12/14 on first-paint levers and 12/14 on other features. Rank 3 of 23. Labels: 11 1st-party, 0 Experimental, 2 Third-party, 1 Manual.

- Version checked: Astro 7.4.13 (npm latest on 2026-11-20; labels were drafted against 7.4.10, and the astro-books port locks 7.4.12)
- Performance guide: [Why Astro? | Docs](https://docs.astro.build/en/concepts/why-astro/)
- Issue tracker: https://github.com/withastro/astro/issues
- Books demo port: [astro-books](https://github.com/MaxwellCohen/astro-books)

## Summary

| Feature | Group | Label | Points |
| --- | --- | --- | --- |
| [Production CSS inlining](https://framework-compare.vercel.app/features/css-inlining.md) | First-paint levers | 1st-party | 2 |
| [Font optimization](https://framework-compare.vercel.app/features/font-optimization.md) | First-paint levers | 1st-party | 2 |
| [Image pipeline](https://framework-compare.vercel.app/features/image-pipeline.md) | First-paint levers | 1st-party | 2 |
| [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 | 1st-party | 2 |
| [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 | 1st-party | 2 |
| [Portable multi-host deployment](https://framework-compare.vercel.app/features/multi-host-deployment.md) | Other features | 1st-party | 2 |
| [Service worker / offline support](https://framework-compare.vercel.app/features/service-worker.md) | Other features | Third-party | 1 |

## First-paint levers

### Production CSS inlining

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

`build.inlineStylesheets: 'always' | 'auto' | 'never'` (stable, astro@2.6.0+). Default `auto` inlines styles under 4kB and links larger ones; `'always'` inlines all. ([configuration-reference](https://docs.astro.build/en/reference/configuration-reference/), [styling](https://docs.astro.build/en/guides/styling/))

Example of building it yourself:

`build.inlineStylesheets` controls whether project CSS ships as `<style>` tags or linked files. `'always'` inlines every stylesheet; the default `'auto'` inlines only files under Vite's 4kB `assetsInlineLimit`.

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  build: {
    inlineStylesheets: 'always', // 'auto' (default) | 'never'
  },
});
```

Source: [Astro: configuration reference, build.inlineStylesheets](https://docs.astro.build/en/reference/configuration-reference/#buildinlinestylesheets)

### Font optimization

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

Fonts API: top-level `fonts` config (astro@6.0.0+) plus `<Font cssVariable preload />` from `astro:assets`, not under experimental flags. Providers include Google, Bunny, Fontsource, Fontshare, Adobe, local; fonts are downloaded, cached, served from `_astro/fonts`, with a `subsets` option (default `latin`) and optimized fallbacks. `preload` defaults to false. ([fonts](https://docs.astro.build/en/guides/fonts/), [astro-assets](https://docs.astro.build/en/reference/modules/astro-assets/))

Example of building it yourself:

Register the font in the top-level `fonts` config, then render `<Font />` in the layout head. Astro downloads and serves the files itself, and `preload` adds a preload link.

```js
// astro.config.mjs
import { defineConfig, fontProviders } from 'astro/config';

export default defineConfig({
  fonts: [{
    provider: fontProviders.fontsource(),
    name: 'Roboto',
    cssVariable: '--font-roboto',
  }],
});
```

```astro
---
// src/layouts/Layout.astro
import { Font } from 'astro:assets';
---
<html>
  <head>
    <Font cssVariable="--font-roboto" preload />
  </head>
  <body><slot /></body>
</html>
```

Source: [Astro: Using custom fonts](https://docs.astro.build/en/guides/fonts/)

### Image pipeline

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

`<Image />` from `astro:assets` optimizes local and authorized remote images; Sharp is the default service; responsive `layout`/`srcset` since astro@5.10.0; `public/` images are not optimized. Cloudflare, Vercel, and Netlify adapters have host image services. ([images](https://docs.astro.build/en/guides/images/), [cloudflare](https://docs.astro.build/en/guides/integrations-guide/cloudflare/), [vercel](https://docs.astro.build/en/guides/integrations-guide/vercel/), [netlify](https://docs.astro.build/en/guides/integrations-guide/netlify/))

Example of building it yourself:

`<Image />` from `astro:assets` resizes and converts imported local images at build time. `layout="constrained"` adds a responsive `srcset`, and `image.domains` lets remote images through the same pipeline.

```astro
---
// src/components/Cover.astro
import { Image } from 'astro:assets';
import cover from '../assets/cover.jpg';
---
<Image src={cover} alt="Book cover" layout="constrained" width={800} height={600} />
```

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  image: {
    domains: ['covers.example.com'],
  },
});
```

Source: [Astro: Images](https://docs.astro.build/en/guides/images/)

Art direction with `<picture>` (1st-party, not scored):

`<Picture />` (astro@3.3.0+) emits `<picture>` with `formats` (default `webp`) plus a fallback `<img>`. Breakpoint art direction is not in the component docs; the official recipe uses `getImage()` and a hand-written `<picture>`/`<source media>`. ([astro-assets](https://docs.astro.build/en/reference/modules/astro-assets/), [build-custom-img-component](https://docs.astro.build/en/recipes/build-custom-img-component/))

`<Picture />` handles formats, not breakpoints. Astro's recipe calls `getImage()` once per crop and writes the `<picture>` by hand.

```astro
---
// src/components/Hero.astro
import { getImage } from "astro:assets";
import wide from "../assets/hero-wide.jpg";
import square from "../assets/hero-square.jpg";

const desktop = await getImage({ src: wide, width: 1600, format: "avif" });
const mobile = await getImage({ src: square, width: 600, format: "webp" });
const fallback = await getImage({ src: square, width: 600 });
---
<picture>
  <source media="(min-width: 768px)" srcset={desktop.src} type="image/avif" />
  <source srcset={mobile.src} type="image/webp" />
  <img src={fallback.src} {...fallback.attributes} alt="Shelves of books" />
</picture>
```

Source: [Astro: build a custom image component](https://docs.astro.build/en/recipes/build-custom-img-component/)

Gotchas:

- The Vercel image service requests `q=100` unless `quality` is set on `<Image>`.

### Data/HTML caching

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

Route caching for on-demand pages (astro@7.0.0+): top-level `cache: { provider }` with `memoryCache()`, `Astro.cache.set({ maxAge, swr, tags })`, `routeRules`, `cache.invalidate()`. Host providers (`cacheNetlify()`, `cacheVercel()`, `cacheCloudflare()`) are experimental and manually enabled. Also Vercel `isr: true` and Netlify `cacheOnDemandPages`. ([caching](https://docs.astro.build/en/guides/caching/), [astro-7](https://astro.build/blog/astro-7/), [vercel](https://docs.astro.build/en/guides/integrations-guide/vercel/), [netlify](https://docs.astro.build/en/guides/integrations-guide/netlify/))

Example of building it yourself:

Pick a cache provider in the config, then set cache options from an on-demand page. `routeRules` sets defaults for groups of routes, and `cache.invalidate()` purges by tag or path.

```js
// astro.config.mjs
import { defineConfig, memoryCache } from 'astro/config';

export default defineConfig({
  cache: { provider: memoryCache() },
  routeRules: {
    '/books/[...slug]': { maxAge: 3600, tags: ['books'] },
  },
});
```

```astro
---
// src/pages/index.astro
export const prerender = false;
Astro.cache.set({ maxAge: 120, swr: 60, tags: ['home'] });
---
```

```ts
// src/pages/api/revalidate.ts
import type { APIRoute } from 'astro';

export const POST: APIRoute = async (context) => {
  await context.cache.invalidate({ tags: ['books'] });
  return new Response(null, { status: 204 });
};
```

Source: [Astro: Route caching](https://docs.astro.build/en/guides/caching/)

Gotchas:

- Vercel ISR in `@astrojs/vercel` ignores query strings (`allowQuery`), so pages driven by search params use the route cache with the adapter's CDN provider instead.

### Route prefetching

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

`prefetch: true` adds the script; links opt in via `data-astro-prefetch` or `prefetch.prefetchAll: true`. Strategies `hover` (default), `tap`, `viewport`, `load`; falls back to `tap` on data saver. `<ClientRouter />` pages prefetch by default. `eagerness` and Speculation Rules need experimental `clientPrerender`. ([prefetch](https://docs.astro.build/en/guides/prefetch/))

Example of building it yourself:

`prefetch: true` turns on the prefetch script. Links opt in with `data-astro-prefetch` and a strategy, or `prefetchAll` covers every link.

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  prefetch: {
    prefetchAll: true,
    defaultStrategy: 'viewport', // 'hover' (default) | 'tap' | 'viewport' | 'load'
  },
});
```

```astro
<!-- src/components/Nav.astro -->
<a href="/books" data-astro-prefetch="tap">Books</a>
<a href="/account" data-astro-prefetch="false">Account</a>
```

Source: [Astro: Prefetch](https://docs.astro.build/en/guides/prefetch/)

### Streaming SSR

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

On-demand pages use HTML streaming: the document is sent in chunks, in order, as each component renders, so `<head>` and the top of the page go out before a slow `await` further down finishes. Nothing to enable. Move slow fetches into child components so they do not block the parts above them; `server:defer` server islands cover content that should arrive out of order. ([on-demand-rendering](https://docs.astro.build/en/guides/on-demand-rendering/#html-streaming))

Example of building it yourself:

On-demand pages stream by default. Put a slow fetch in its own component: the HTML above it is sent while it waits.

```astro
---
// src/pages/books/[id].astro
export const prerender = false; // render on demand
import Layout from "../../layouts/Layout.astro";
import BookDetail from "../../components/BookDetail.astro";
import Reviews from "../../components/Reviews.astro";
---
<Layout title="Book">
  <BookDetail id={Astro.params.id} />
  <!-- head, header and BookDetail are already sent while Reviews awaits -->
  <Reviews id={Astro.params.id} />
</Layout>
```

```astro
---
// src/components/Reviews.astro
const res = await fetch(`https://api.example.com/books/${Astro.props.id}/reviews`);
const reviews = await res.json();
---
<ul>{reviews.map((r) => <li>{r.text}</li>)}</ul>
```

Source: [Astro: On-demand rendering, HTML streaming](https://docs.astro.build/en/guides/on-demand-rendering/#html-streaming), [Astro: Streaming for page performance](https://docs.astro.build/en/recipes/streaming-improve-page-performance/)

### Early Hints / preload headers

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

No first-party preload `Link` headers or 103 Early Hints documented; the configuration reference has no option for either. Set a `Link` header by hand with `Astro.response.headers` or at the host. ([configuration-reference](https://docs.astro.build/en/reference/configuration-reference/), [on-demand-rendering](https://docs.astro.build/en/guides/on-demand-rendering/))

Example of building it yourself:

Set a `Link` header on HTML responses in the middleware. This one preconnects to the font host. To preload a built file with a hashed name, read its URL from the Vite manifest.

```ts
// src/middleware.ts
import { defineMiddleware } from 'astro:middleware'

const LINK = '<https://fonts.gstatic.com>; rel=preconnect; crossorigin'

export const onRequest = defineMiddleware(async (_context, next) => {
  const response = await next()
  if (!response.headers.get('content-type')?.includes('text/html')) return response
  const headers = new Headers(response.headers)
  headers.set('Link', LINK)
  return new Response(response.body, { status: response.status, statusText: response.statusText, headers })
})
```

Source: [Astro middleware](https://docs.astro.build/en/guides/middleware/)

## Other features

### Islands / partial hydration / lazy slices

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

Zero client JS by default; `client:load`, `client:idle`, `client:visible`, `client:media`, `client:only`. `server:defer` server islands need an adapter; props travel in an encrypted query string. Server islands were experimental in astro@4.12 (`experimental.serverIslands`) and the flag was removed in astro@5.0, where the feature is available without it; the guide carries no experimental label. ([islands](https://docs.astro.build/en/concepts/islands/), [framework-components](https://docs.astro.build/en/guides/framework-components/), [server-islands](https://docs.astro.build/en/guides/server-islands/), [upgrade-to/v5](https://docs.astro.build/en/guides/upgrade-to/v5/), [astro-4120](https://astro.build/blog/astro-4120/))

Example of building it yourself:

Components render to HTML with no client JS unless a `client:*` directive hydrates them. `server:defer` turns an Astro component into a server island that renders after the page, with fallback content until it arrives.

```astro
---
// src/pages/index.astro
import Counter from '../components/Counter.jsx';
import Avatar from '../components/Avatar.astro';
import GenericAvatar from '../components/GenericAvatar.astro';
---
<Counter client:visible />

<Avatar server:defer>
  <GenericAvatar slot="fallback" />
</Avatar>
```

Source: [Astro: Server islands](https://docs.astro.build/en/guides/server-islands/)

### Per-route render modes

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

Default static; `export const prerender = false` per page/endpoint for on-demand rendering; with `output: 'server'`, `prerender = true` opts back in. On-demand pages need an adapter. ([on-demand-rendering](https://docs.astro.build/en/guides/on-demand-rendering/))

Example of building it yourself:

Pages prerender by default. `export const prerender = false` renders one page on demand; with `output: 'server'`, `prerender = true` opts a page back into static output.

```astro
---
// src/pages/[id].astro
export const prerender = false; // render on each request (needs an adapter)

const { id } = Astro.params;
---
<h1>Book {id}</h1>
```

Source: [Astro: On-demand rendering](https://docs.astro.build/en/guides/on-demand-rendering/)

### Fine-grained client reactivity

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

No reactivity of its own in `.astro` components; the official Astro-team integrations `@astrojs/solid-js`, `@astrojs/svelte`, and `@astrojs/vue` (installed with `astro add`) bring Solid signals, Svelte runes, and Vue refs to islands. ([framework-components](https://docs.astro.build/en/guides/framework-components/), [solid-js](https://docs.astro.build/en/guides/integrations-guide/solid-js/), [svelte](https://docs.astro.build/en/guides/integrations-guide/svelte/), [vue](https://docs.astro.build/en/guides/integrations-guide/vue/))

Example of building it yourself:

`.astro` components have no client state. Add a UI framework integration (here Solid via `astro add solid`) and use its signals inside an island.

```tsx
// src/components/Counter.tsx
import { createSignal } from 'solid-js';

export default function Counter() {
  const [count, setCount] = createSignal(0);
  return <button onClick={() => setCount(count() + 1)}>Clicked {count()}</button>;
}
```

```astro
---
// src/pages/index.astro
import Counter from '../components/Counter';
---
<Counter client:load />
```

Source: [Astro: @astrojs/solid-js](https://docs.astro.build/en/guides/integrations-guide/solid-js/)

### Built-in bundle analysis

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

No first-party analyzer documented; the official recipe adds `rollup-plugin-visualizer`, with a caveat that the report may not match what the client downloads. ([analyze-bundle-size](https://docs.astro.build/en/recipes/analyze-bundle-size/))

Example of building it yourself:

Astro's recipe adds `rollup-plugin-visualizer` as a Vite plugin. `astro build` then writes `stats.html`. The report covers the whole site, not each page.

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import { visualizer } from 'rollup-plugin-visualizer';

export default defineConfig({
  vite: {
    plugins: [visualizer({ emitFile: true, filename: 'stats.html' })],
  },
});
```

Source: [Astro: Analyze bundle size](https://docs.astro.build/en/recipes/analyze-bundle-size/)

Gotchas:

- Astro's recipe warns that a visualizer report may not match what the client downloads.

### Third-party script strategies

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

Official `@astrojs/partytown` integration: `astro add partytown`, then `type="text/partytown"` on scripts. ([partytown](https://docs.astro.build/en/guides/integrations-guide/partytown/))

Example of building it yourself:

Install the integration with `npx astro add partytown`, then mark scripts `type="text/partytown"` so they run in a web worker. `forward` exposes globals such as `dataLayer.push` to the worker.

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import partytown from '@astrojs/partytown';

export default defineConfig({
  integrations: [partytown({ config: { forward: ['dataLayer.push'] } })],
});
```

```astro
<!-- src/layouts/Layout.astro -->
<script type="text/partytown" src="https://example.com/analytics.js"></script>
```

Source: [Astro: @astrojs/partytown](https://docs.astro.build/en/guides/integrations-guide/partytown/)

### Portable multi-host deployment

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

Official adapters for Node (standalone/middleware), Vercel, Netlify, and Cloudflare; the on-demand rendering page names all four as official, and `astro add <adapter>` installs them. ([on-demand-rendering](https://docs.astro.build/en/guides/on-demand-rendering/), [deploy](https://docs.astro.build/en/guides/deploy/), [node](https://docs.astro.build/en/guides/integrations-guide/node/), [vercel](https://docs.astro.build/en/guides/integrations-guide/vercel/), [netlify](https://docs.astro.build/en/guides/integrations-guide/netlify/), [cloudflare](https://docs.astro.build/en/guides/integrations-guide/cloudflare/))

Example of building it yourself:

The Books port picks an official adapter from the build environment and falls back to Node. Each adapter is installed with `astro add <name>`.

```js
// astro.config.mjs
import node from '@astrojs/node';
import { defineConfig } from 'astro/config';

async function pickAdapter() {
  if (process.env.NETLIFY) return (await import('@astrojs/netlify')).default();
  if (process.env.CF_PAGES) return (await import('@astrojs/cloudflare')).default();
  if (process.env.VERCEL) return (await import('@astrojs/vercel')).default();
  return node({ mode: 'standalone' });
}

export default defineConfig({
  output: 'server',
  adapter: await pickAdapter(),
});
```

Source: [Astro: @astrojs/node](https://docs.astro.build/en/guides/integrations-guide/node/)

### Service worker / offline support

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

No first-party service worker documented. The community `@vite-pwa/astro` integration (2.0.4) generates the worker and precache manifest with Workbox and registers it; the Astro docs do not mention it. ([vite-pwa astro](https://vite-pwa-org.netlify.app/frameworks/astro))

Example of building it yourself:

Add the `@vite-pwa/astro` integration, which generates a Workbox worker and precache manifest at build time. Register it from the main layout.

```js
// astro.config.mjs (npm install -D @vite-pwa/astro)
import { defineConfig } from "astro/config";
import AstroPWA from "@vite-pwa/astro";

export default defineConfig({
  integrations: [AstroPWA({ workbox: { navigateFallback: "/404" } })],
});
```

```astro
---
// src/layouts/Layout.astro
import { pwaInfo } from "virtual:pwa-info";
---
<head>
  <script src="/src/pwa.ts"></script>
  {pwaInfo && <Fragment set:html={pwaInfo.webManifest.linkTag} />}
</head>
```

```ts
// src/pwa.ts
import { registerSW } from "virtual:pwa-register";
registerSW({ immediate: true });
```

Source: [Vite PWA: Astro](https://vite-pwa-org.netlify.app/frameworks/astro)

## Other performance features

- `<ClientRouter />` view transitions with a simulated `animate` fallback. ([view-transitions](https://docs.astro.build/en/guides/view-transitions/))
- Node adapter standalone sends `Cache-Control: public, max-age=31536000, immutable` for hashed `_astro/` assets. ([node](https://docs.astro.build/en/guides/integrations-guide/node/))
- Astro 7: Rolldown via Vite 8, Rust `.astro` compiler, queued rendering stable and default. ([astro-7](https://astro.build/blog/astro-7/))
- `security.csp` (astro@6.0.0+, default false) adds a per-page CSP `<meta>` with `script-src`/`style-src` hashes for bundled scripts and styles; it is not supported in dev mode and does not work with `<ClientRouter />` view transitions or Shiki. ([configuration-reference](https://docs.astro.build/en/reference/configuration-reference/))

## Deployments of the Books demo

| Branch | Note | Vercel | Netlify | Cloudflare |
| --- | --- | --- | --- | --- |
| `main` | vibe port | https://astro-books-eta.vercel.app | https://max-astro-books.netlify.app | https://astro-books.to-email-max.workers.dev |
| `optimized` | cache + fonts | https://astro-books-optimized.vercel.app | https://astro-books-max-optimized.netlify.app | https://astro-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 | 85 | 1.53 s | 1.35 s | 4.36 s | 0 ms | 0.000 |
| book list (/) | optimized | `optimized` | cloudflare, netlify, vercel | 98 | 0.94 s | 0.21 s | 2.06 s | 0 ms | 0.001 |
| one book (/10145787) | baseline | `main` | cloudflare, netlify, vercel | 96 | 1.52 s | 0.95 s | 2.57 s | 0 ms | 0.000 |
| one book (/10145787) | optimized | `optimized` | cloudflare, netlify, vercel | 100 | 0.93 s | 0.21 s | 1.25 s | 0 ms | 0.000 |

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

---

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