A Google Font does not show in the Next.js App Router
How to import custom google fonts in NextJS 13? Link tags not workingShort answer
In the App Router the supported way to load a Google Font is next/font/google, not a hand-written link tag. Call the font function at module level, then put its className or CSS variable on an element, usually the html tag in the root layout. A font that is loaded but never applied, or missing a weight, will not show.
Fix it fast
1Find out which cause you have
Open the root layout and see whether a font function is called and whether its class reaches an element.
grep -rn "next/font\|fonts.googleapis\|className=" app/layout.tsx2Match what you see, then jump to its fix
- 1
next/font/google is imported, yet text stays in the default font.The font is loaded but its className is never appliedFix - 2
The font is not a variable font and the call has no weight option.A font that is not variable has no weightFix - 3
Import of 'Roboto Mono' fails, or font-sans and font-mono utilities do nothing.The font name has a space, or the CSS variable is not mapped in TailwindFix - 4
The font shows on one route and not on others.The font is created in a page, so it is not on every routeFix
- 1
What does the error look like?
How to import custom google fonts in NextJS 13? Link tags not working
Cause 1 of 4
The font is loaded but its className is never applied
1Check
The font function returns a className. Fonts are scoped to the component where that class is used, so the class must reach the elements you want.
grep -n "className" app/layout.tsx2Fix
Create the font once at module level and put its className on the html element of the root layout. Fonts applied there cover the whole app.
// app/layout.tsx
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'], display: 'swap' })
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={inter.className}>
<body>{children}</body>
</html>
)
}3Verify
Open DevTools, select a paragraph and look at the computed font-family.
npm run devConfirmed by nextjs.org
Cause 2 of 4
A font that is not variable has no weight
1Check
A weight is required when the Google font is not a variable font. A variable font can omit it.
grep -rn "Google\|weight" app/layout.tsx2Fix
Pass weight as a string or an array, and style when you need italics.
import { Roboto } from 'next/font/google'
const roboto = Roboto({
weight: ['400', '700'],
style: ['normal', 'italic'],
subsets: ['latin'],
display: 'swap',
})3Verify
Restart the dev server; both weights show in the Network tab as font files from your own domain.
npm run devConfirmed by nextjs.org
Cause 3 of 4
The font name has a space, or the CSS variable is not mapped in Tailwind
1Check
Multi-word names use an underscore in the import, such as Roboto_Mono. A font loaded with the variable option only declares a CSS variable; your styles must read it.
grep -rn "variable:\|--font-" app2Fix
Import with the underscore, set variable, add the variable class to html, and map the variable in your theme.
// app/layout.tsx
import { Inter, Roboto_Mono } from 'next/font/google'
const inter = Inter({ subsets: ['latin'], variable: '--font-inter' })
const mono = Roboto_Mono({ subsets: ['latin'], variable: '--font-roboto-mono' })
// <html className={`${inter.variable} ${mono.variable}`}>
/* global.css (Tailwind v4) */
@import 'tailwindcss';
@theme inline {
--font-sans: var(--font-inter);
--font-mono: var(--font-roboto-mono);
}3Verify
A paragraph with class font-mono renders in Roboto Mono.
npm run devConfirmed by nextjs.org
Cause 4 of 4
The font is created in a page, so it is not on every route
1Check
A font called in a page is preloaded only on that route. A font in a layout covers the routes wrapped by it. The root layout covers all routes.
grep -rln "next/font/google" app2Fix
Move the call to a shared fonts file or the root layout, and import the font object where it is needed. Each call to the function creates one hosted instance, so do not repeat it.
// app/fonts.ts
import { Inter, Roboto_Mono } from 'next/font/google'
export const inter = Inter({ subsets: ['latin'] })
export const robotoMono = Roboto_Mono({ subsets: ['latin'] })3Verify
Visit two different routes and compare the computed font.
npm run devConfirmed by nextjs.org
How do I stop it coming back?
- Always pass subsets to a Google font; leaving it out while preload is on gives a warning.
- Define fonts in one file and import them, so each font is hosted once.
- Prefer variable fonts; they need no weight list.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
ESLint fails with: Cannot find module 'next/babel'
ESLint stops on the first file with a Babel or parser error instead of listing lint results
next/babel is a Babel preset that ships inside the next package.
3 causes, each with a fixWeb apps
ESLint says an element in a list is missing its key prop
react/jsx-key
react/jsx-key fires when an element returned from map, Array.from or an array literal has no key.
3 causes, each with a fix