If you started a Next.js project recently and noticed there is no @font-face block anywhere, that is next/font working. It moved the entire font-loading problem from your stylesheet into the framework. Here is what it solves and what it still cannot.
What next/font does automatically
No layout shift. next/font self-hosts the font and injects size-adjusted fallback metrics, so the FOUT flash becomes invisible - the fallback occupies exactly the same space as the real font.
Zero render-blocking requests. The font files are served from your own origin with preload headers handled by the framework.
Automatic subsetting. Google fonts via next/font/google ship only the subsets you declare.
import { Inter, JetBrains_Mono } from 'next/font/google';
const inter = Inter({ subsets: ['latin'], display: 'swap' });
const mono = JetBrains_Mono({ subsets: ['latin'], variable: '--font-mono' });
export default function RootLayout({ children }) {
return (
<html lang="en" className={`${inter.className} ${mono.variable}`}>
<body>{children}</body>
</html>
);
}
What it cannot solve
- Choosing the right font. The framework ships whatever you declare. If a migration audit finds the wrong family actually rendering, fix the declaration - and identify what the old build really used from a screenshot with an on-device tool like Typeye before writing the new config.
- License compliance for self-hosted files. next/font/local ships your files; the license must allow self-hosting. Google Fonts are licensed for this automatically, commercial foundries vary.
- Non-Next projects. Astro, Remix, and plain Vite apps still need manual preload + size-adjust fallback setup.
The migration checklist
- Inventory current @font-face declarations and their actual usage (DevTools Font filter).
- Replace with next/font/google (or local) declarations.
- Delete the old CSS @font-face blocks and their preload hints.
- Verify with Lighthouse: the "preload key requests" and "layout shift" audits should both clear.
One import, two fewer audits to worry about.
Top comments (0)