Skip to content

Early Hints / preload headers

A Link: </assets/app.css>; rel=preload; as=style response header names a critical asset before the browser has parsed any HTML. A 103 Early Hints response sends those Link headers while the server is still rendering, so the stylesheet, font, and script requests start during the server's think time. The row is ✅ when the framework adds preload Link headers for its own built assets, or sends the 103 itself, without the app listing assets by hand. Setting a Link header through a generic headers API is 🔧. A CDN such as Cloudflare can turn a cached Link header into a 103 (Cloudflare Early Hints), which is why preload headers count here even when the framework never writes a 103.

07 / 14First-paint leverOne of 7 features that affect first paint, the moment the browser first draws content. Together they are worth 14 of the 28 points.

Labels across 23 frameworks

  • 1st-party4
  • Experimental3
  • Third-party0
  • Manual16
  • of 23

How to enable it, by framework

One card per framework, in the same order on every feature page. Where a framework has no built-in support (Manual), a short example shows how to build it yourself.

Next

1st-party2 ptsOverview

Nothing to enable in the App Router. During prerendering React emits preload headers for fonts, scripts, and stylesheets, and Next adds them to the response. reactMaxHeadersLength caps their total length (default 6000) for proxies that truncate long headers. Next does not document sending a 103 itself.

module.exports = {
  reactMaxHeadersLength: 1000,
}

From the reactMaxHeadersLength docs.

SvelteKit

1st-party2 ptsOverview

Set output.linkHeaderPreload: true (SvelteKit 3.0+, default false). Pages that are not prerendered then preload their JS and CSS through the HTTP Link header instead of <link> elements. SvelteKit does not document sending a 103 itself.

sveltekit({
  output: {
    linkHeaderPreload: true,
  },
})

Adapted from the output config docs; the option sits next to inlineStyleThreshold in this repo's svelte-books/vite.config.ts, which does not set it.

No first-party preload headers or Early Hints are documented. httpHeader sets a response header during SSR, so you list each asset yourself.

httpHeader("Link", "</fonts/inter.woff2>; rel=preload; as=font", {
  append: true,
});

From the Solid httpHeader reference.

Early Hints are marked experimental. Start collects route assets and route head().links and calls onEarlyHints in your server entry; your code sends the 103 with the runtime's own API, because "Start does not send Early Hints automatically". responseLinkHeader puts the same links in a Link header for a CDN to convert.

// src/server.ts
import handler, { createServerEntry } from '@tanstack/react-start/server-entry'

export default createServerEntry({
  fetch(request) {
    return handler.fetch(request, {
      onEarlyHints: ({ phase, links }) => {
        if (phase !== 'static' || !links.length) return

        // Send `links` with your runtime-specific 103 API.
      },
    })
  },
})

From the TanStack Start Early Hints guide.

The same experimental onEarlyHints hook and responseLinkHeader option, imported from @tanstack/solid-start/server-entry.

Code example

Pass onEarlyHints to handler.fetch() in the server entry. It receives the manifest's preload links, which you send with the runtime's 103 API. responseLinkHeader: true puts them in a Link header instead.

// src/server.ts
import handler from '@tanstack/solid-start/server-entry'
import type { ServerRequest } from 'srvx'

export default {
  fetch(request: Request) {
    const serverRequest = request as ServerRequest
    return handler.fetch(request, {
      onEarlyHints: ({ phase, allLinks }) => {
        if (phase !== 'dynamic') return
        const response = serverRequest.runtime?.node?.res
        if (response?.writeEarlyHints && allLinks.length) {
          response.writeEarlyHints({ link: allLinks })
        }
      },
    })
  },
}

Source: TanStack Start: Early Hints

Pracht

1st-party2 ptsOverview

Nothing to enable for the header: rendered pages, and prerendered SSG/ISG pages on the Node, Cloudflare, Vercel, and Netlify adapters, send a preload Link header for their stylesheets (performance guide, Early hints). On the Node adapter, earlyHints: true sends the 103 itself, including the page's scripts, before the loaders run.

nodeAdapter({ earlyHints: true });

From the Pracht performance guide.

Waku

Manual0 ptsOverview

No first-party preload headers or Early Hints are documented on waku.gg. Add a Link header at the host or CDN.

Code example

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

// src/middleware/link-header.ts
import type { MiddlewareHandler } from 'hono';

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

export default (): MiddlewareHandler => async (c, next) => {
  await next();
  if (c.res.headers.get('content-type')?.includes('text/html')) c.res.headers.set('Link', LINK);
};

Source: Hono middleware

Ember

Manual0 ptsOverview

No first-party preload headers or Early Hints are documented in the FastBoot user guide or in vite-ember-ssr. Set a Link header in the Node server that wraps the renderer, or at the host.

Code example

Set a Link header on the Fastify reply that sends the rendered page. This one preconnects to the font host. To preload a built file with a hashed name, read its URL from the Vite manifest.

// server.js
const LINK = '<https://fonts.gstatic.com>; rel=preconnect; crossorigin';
// … in the handler that sends the SSR result
const { html } = await renderHtml(emberApp, request.url, template);
return reply.header('Link', LINK).type('text/html').send(html);

Source: Fastify Reply: .header()

Astro

Manual0 ptsOverview

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, on-demand-rendering)

Code example

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.

// 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

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)

Code example

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.

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

Source: React Router: HTTP headers

No first-party preload Link headers or 103 Early Hints documented; the preloader works through <link rel="modulepreload"> tags in the HTML. Set a Link header by hand with headers.set() in a request handler. (speculative-module-fetching, caching)

Code example

Set a Link header in the root layout's onGet handler. This one preconnects to the font host. To preload a built file with a hashed name, read its URL from the Vite manifest.

// src/routes/layout.tsx
import type { RequestHandler } from '@builder.io/qwik-city'

export const onGet: RequestHandler = async ({ headers }) => {
  headers.set('Link', '<https://fonts.gstatic.com>; rel=preconnect; crossorigin')
}

Source: Qwik City: caching and response headers

No first-party preload Link headers or 103 Early Hints documented. Per-route headers in ServerRoute and RESPONSE_INIT can set a Link header by hand. (ssr)

Code example

Add a Link header to the server route's headers. This one preconnects to the font host. To preload a built file with a hashed name, read its URL from the Vite manifest.

// src/app/app.routes.server.ts
import { RenderMode, ServerRoute } from '@angular/ssr';

export const serverRoutes: ServerRoute[] = [
  {
    path: '**',
    renderMode: RenderMode.Server,
    headers: { Link: '<https://fonts.gstatic.com>; rel=preconnect; crossorigin' },
  },
];

Source: Angular SSR: setting headers and status codes

Marko

Manual0 ptsOverview

No first-party preload Link headers or 103 Early Hints documented. Handlers return web-standard Response objects, so a Link header is set by hand in a +handler or +middleware file. (file-based-routing)

Code example

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

// src/routes/+middleware.ts
const LINK = '<https://fonts.gstatic.com>; rel=preconnect; crossorigin';

export default async (_ctx: unknown, next: () => Promise<Response>) => {
  const response = await next();
  if (response.headers.get('content-type')?.includes('text/html')) response.headers.append('Link', LINK);
  return response;
};

Source: Marko Run: file-based routing

Fresh

Manual0 ptsOverview

No first-party preload Link headers or 103 Early Hints documented. Set a Link header by hand through page(data, { headers }) or a middleware. (data-fetching)

Code example

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

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

app.use(async (ctx) => {
  const res = await ctx.next();
  if (res.headers.get('content-type')?.includes('text/html')) res.headers.append('Link', LINK);
  return res;
});

Source: Fresh middleware

Analog

Manual0 ptsOverview

No first-party preload Link headers or 103 Early Hints documented. Set a Link header by hand with h3 setResponseHeader in server middleware. (middleware)

Code example

Set a Link header by hand in server middleware. Files in src/server/middleware/ are registered automatically.

// src/server/middleware/preload.ts
import { defineEventHandler, setResponseHeader } from 'h3';

export default defineEventHandler((event) => {
  if (event.path.startsWith('/api')) return;
  setResponseHeader(
    event,
    'Link',
    '<https://fonts.gstatic.com>; rel=preconnect; crossorigin, </media/hero-1280.avif>; rel=preload; as=image',
  );
});

Source: Analog: Middleware

Vike

1st-party2 ptsOverview

Vike builds the list of a page's assets as pageContext.httpResponse.earlyHints (each entry has an earlyHintLink value), so the app does not list assets by hand. The server sends the 103 with its runtime's API, e.g. res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) }) on Node 18+. Not marked experimental or beta. (preloading)

Code example

renderPage() returns the page's assets in pageContext.httpResponse.earlyHints. Pass their earlyHintLink values to the runtime's 103 API before sending the body.

// server.ts
import { renderPage } from 'vike/server'

app.get('*', async (req, res) => {
  const pageContext = await renderPage({ urlOriginal: req.originalUrl })
  const { earlyHints } = pageContext.httpResponse
  // For example with Node.js 18:
  res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
  // … then send pageContext.httpResponse as usual
})

Source: Vike: Preloading

No first-party preload Link headers or 103 Early Hints documented; the Document example hand-writes <link rel="modulepreload" href="/src/client.tsx" />. Set a Link header by hand with requestInfo.response.headers in middleware. (documents, routing)

Code example

Add a middleware that sets a Link header on every response. This one preloads a font from public/, whose URL does not change between builds. Cloudflare can turn Link preload headers into 103 Early Hints when Early Hints is on for the zone.

// src/app/headers.ts
import type { RouteMiddleware } from "rwsdk/worker";

export const preloadHeaders = (): RouteMiddleware => ({ response }) => {
  response.headers.append(
    "Link",
    "</fonts/brand-font.woff2>; rel=preload; as=font; type=font/woff2; crossorigin",
  );
};

// src/worker.tsx
export default defineApp([
  preloadHeaders(),
  render(Document, [route("/", HomePage)]),
]);

Source: RedwoodSDK: Security · Cloudflare: Early Hints

Remix 3

Manual0 ptsOverview

No first-party preload Link headers or 103 Early Hints documented; the asset server returns module preloads that the document renders as <link rel="modulepreload"> tags. Set a Link header by hand on the returned Response. (assets, files-and-assets)

Code example

There is no Early Hints API, so set a Link preload header yourself on the response the action returns.

// app/actions/books/controller.tsx
import { assets, stylesheetHref } from "../../assets.ts";

// inside the show action:
let coverHref = await assets.getHref("app/ui/public/cover.jpg");

return context.render(<BookPage book={book} coverHref={coverHref} />, {
  headers: {
    Link: [
      `<${stylesheetHref}>; rel=preload; as=style`,
      `<${coverHref}>; rel=preload; as=image; fetchpriority=high`,
    ].join(", "),
  },
});

Source: Remix: Rendering UI, rendering pages through request context

No preload Link response headers or 103 Early Hints documented. assetTags.preloads puts <link rel="modulepreload"> tags in the HTML <head>, not in headers. Set a Link header by hand with routing.headers or c.header(). (handlers, headers)

Code example

Void sends no 103 and no preload Link header. It only puts <link rel="modulepreload"> tags in the HTML. Add the header yourself with routing.headers.

// void.config.ts
import { defineConfig } from 'void/config'

export default defineConfig({
  routing: { headers: { '/*': ['Link: </fonts/geist.woff2>; rel=preload; as=font; crossorigin'] } },
})

Source: Void: Headers

No preload Link response headers or 103 Early Hints documented. assetTags.preloads puts <link rel="modulepreload"> tags in the HTML <head>, not in headers. Set a Link header by hand with routing.headers or c.header(). (handlers, headers)

Code example

Void sends no 103 and no preload Link header. It only puts <link rel="modulepreload"> tags in the HTML. Add the header yourself with routing.headers.

// void.config.ts
import { defineConfig } from 'void/config'

export default defineConfig({
  routing: { headers: { '/*': ['Link: </fonts/geist.woff2>; rel=preload; as=font; crossorigin'] } },
})

Source: Void: Headers

No preload Link response headers or 103 Early Hints documented. assetTags.preloads puts <link rel="modulepreload"> tags in the HTML <head>, not in headers. Set a Link header by hand with routing.headers or c.header(). (handlers, headers)

Code example

Void sends no 103 and no preload Link header. It only puts <link rel="modulepreload"> tags in the HTML. Add the header yourself with routing.headers.

// void.config.ts
import { defineConfig } from 'void/config'

export default defineConfig({
  routing: { headers: { '/*': ['Link: </fonts/geist.woff2>; rel=preload; as=font; crossorigin'] } },
})

Source: Void: Headers

No preload Link response headers or 103 Early Hints documented. assetTags.preloads puts <link rel="modulepreload"> tags in the HTML <head>, not in headers. Set a Link header by hand with routing.headers or c.header(). (handlers, headers)

Code example

Void sends no 103 and no preload Link header. It only puts <link rel="modulepreload"> tags in the HTML. Add the header yourself with routing.headers.

// void.config.ts
import { defineConfig } from 'void/config'

export default defineConfig({
  routing: { headers: { '/*': ['Link: </fonts/geist.woff2>; rel=preload; as=font; crossorigin'] } },
})

Source: Void: Headers

Gotchas

  • Browsers act on a 103 only over HTTP/2 or HTTP/3, and some proxies mistake a 103 for the final response. Pracht keeps earlyHints off by default for that reason.
  • Nginx and Apache cap header size, and a long Link header can be truncated or rejected. SvelteKit keeps linkHeaderPreload off by default and Next caps the length for the same reason.
  • A static 103 can go out before a route decides to redirect. TanStack's dynamic phase waits for the loaders to avoid that.
  • Styles that are already inlined need no preload. Pracht sends no Link header for inlineCss styles.