Skip to solution
mediumFrontend

How does next/font work and why does it improve performance?

733 views
01

Understand the problem

Self-hosting fonts with zero layout shift.

nextjsnext-fontfontsperformance
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

next/font downloads and self-hosts fonts (Google or local) at build time, removing external requests and using size-adjust/fallback metrics to eliminate layout shift (CLS). It also strips unused glyphs, improving load performance and privacy.

Solution ready — 2 min read

Classified // press E to declassify

04

Read the code

Load and apply a Google font
// app/layout.tsx
import { Inter } from 'next/font/google';
const inter = Inter({ subsets: ['latin'], display: 'swap' });

export default function RootLayout({ children }) {
  return <html className={inter.className}><body>{children}</body></html>;
}
// Font is self-hosted, subset, and size-adjusted — no external request, no CLS.
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 39 of 95 decoded in the Next.js track. One more won't hurt.

Back to track