Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

A Google Font does not show in the Next.js App Router

ErrorHow to import custom google fonts in NextJS 13? Link tags not working

Short 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.

  • Applies to Next.js 15, Next.js 16
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.tsx
  2. 2Match what you see, then jump to its fix

    1. 1next/font/google is imported, yet text stays in the default font.The font is loaded but its className is never appliedFix
    2. 2The font is not a variable font and the call has no weight option.A font that is not variable has no weightFix
    3. 3Import 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. 4The font shows on one route and not on others.The font is created in a page, so it is not on every routeFix

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.tsx

2Fix

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 dev

Confirmed by nextjs.org

Did this fix it?

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.tsx

2Fix

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 dev

Confirmed by nextjs.org

Did this fix it?

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-" app

2Fix

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 dev

Confirmed by nextjs.org

Did this fix it?

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" app

2Fix

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 dev

Confirmed by nextjs.org

Did this fix it?

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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.