Global application typography
Set the primary typeface for an entire App Router application from the root layout.
Next.js 16+ · Module
next/font/google provides build-time Google Font loaders for Next.js. Fonts are optimized, self-hosted with the deployment, and applied through the loader result.
Import a supported Google font from next/font/google and invoke it with loader options such as subsets. Next.js downloads the font and CSS during the build, self-hosts them with the deployment, and exposes generated styling through the returned object, commonly applied with className.
import { FontName } from 'next/font/google'
const font = FontName(options)| Name | Type | Description |
|---|---|---|
options | Font-specific loader options | Options passed to the selected Google font loader, such as subsets and other font-loading settings. |
A font result object containing generated styling, commonly used through its className property.
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={inter.className}>
<body>{children}</body>
</html>
)
}Imports a Google font loader, configures a subset, and applies the generated class to the root HTML element.
Set the primary typeface for an entire App Router application from the root layout.
Use a selected Google Font subset while avoiding runtime requests to Google.
Apply a font to a specific component or page using the generated class.
next/font/google?Import a font function from next/font/google, call it with configuration, and apply the returned className to an element. Next.js downloads the font and CSS during the build and serves them with the application.
Follow-up: Why does this avoid a browser request to Google? The font files are self-hosted as part of the deployment, so the browser loads them from the application’s origin.
The loader performs automatic optimization and self-hosting, while the generated styles help prevent layout shift. The module is designed to remove external font-network requests from the user’s page load.
Follow-up: What is the build-time implication? CSS and font files must be available when the application builds so they can be included among the static assets.
A font loader is imported as a named export, invoked with options such as subsets, and its returned object supplies the styling used by the component tree. Applying the class at the root layout makes the choice available across the application.
Follow-up: Where is a broad application-wide font commonly applied? In an App Router project, the root layout’s HTML or body element is the natural scope.
next/fontnext/font/localFont Module