next/font automatically optimizes fonts and removes external network requests. It includes built-in self-hosting for any font file, preventing layout shift and improving loading performance.
Google Fonts are downloaded at build time and served with your static assets. No requests are sent to Google by the browser.
- Google font
- Local font
app/layout.js
Options
The path to the font file, relative to where the font loader is called. Used in
next/font/local only.- String:
'./fonts/my-font.woff2' - Array of objects for multiple weights/styles:
next/font/local.The font weight. Can be:
- A single value:
'400' - A range for variable fonts:
'100 900' - An array for non-variable fonts:
['400', '700']
The font style. Defaults to
'normal'. Accepts:- A string:
'italic'or'normal' - An array for multiple styles (Google fonts only):
['italic', 'normal']
Subsets to preload, defined as an array of string names. Used in When
next/font/google only.preload is true (the default), a <link rel="preload"> tag is injected for each specified subset.Additional variable font axes to include. Only the weight axis is included by default to minimize file size. Available values depend on the specific font.Used in
next/font/google only.The CSS
font-display value. Accepts 'auto', 'block', 'swap', 'fallback', or 'optional'.Whether to preload the font. When
true, a <link rel="preload"> tag is injected.Preloading scope depends on where the font is used:- In a page file — preloaded for that route only
- In a layout file — preloaded for all routes wrapped by that layout
- In the root layout — preloaded for all routes
Fallback fonts to use if the primary font cannot be loaded.
Automatically adjusts the fallback font to reduce Cumulative Layout Shift (CLS).
- For
next/font/google: a boolean (defaulttrue) - For
next/font/local:'Arial'(default),'Times New Roman', orfalse
The CSS custom property name for use with the CSS variable method.Exposes the font as
var(--font-inter) in CSS.Additional
@font-face descriptor key-value pairs. Used in next/font/local only.Applying fonts
The font loader returns an object with three ways to apply the font:className
className
A read-only CSS class that applies the font family and fallback.
style
style
A read-only CSS style object with
fontFamily set.CSS variables
CSS variables
Use
variable to expose the font as a CSS custom property, then reference it in external stylesheets.app/page.js
styles/component.module.css
Examples
Google Fonts
Import variable fonts by name. No weight is needed for variable fonts.app/layout.js
app/layout.js
Local fonts
app/layout.js
Multiple fonts
Create a shared font definitions file to avoid duplicate instances:app/fonts.ts
app/layout.js
Tailwind CSS
Use thevariable option to expose fonts as CSS custom properties, then reference them in your Tailwind config.
app/layout.js
global.css
Version history
| Version | Changes |
|---|---|
v13.2.0 | @next/font renamed to next/font |
v13.0.0 | @next/font introduced |
