Use the Geist font family in Next.js 13+ with the Fonts API
Quick Answer
Import Geist from `next/font/google`, instantiate it with variable names, and apply the CSS variables to your root HTML element in the layout.
1// app/layout.tsx
2import { Geist, Geist_Mono } from 'next/font/google';
3
4const geist = Geist({
5 subsets: ['latin'],
6 variable: '--font-geist-sans',
7});
8
9const geistMono = Geist_Mono({
10 subsets: ['latin'],
11 variable: '--font-geist-mono',
12});
13
14export const metadata = {
15 title: 'My App',
16 description: 'Using Geist Font',
17};
18
19export default function RootLayout({
20 children,
21}: {
22 children: React.ReactNode;
23}) {
24 return (
25 <html lang="en" className={`${geist.variable} ${geistMono.variable}`}>
26 <body className="font-sans bg-white text-gray-900">
27 {children}
28 </body>
29 </html>
30 );
31}
32
33// globals.css (optional, for Tailwind config)
34@import 'tailwindcss';
35
36@theme {
37 --font-sans: var(--font-geist-sans), system-ui, sans-serif;
38 --font-mono: var(--font-geist-mono), monospace;
39}Geist is Vercel's modern typeface family — clean, geometric, and highly legible on screens. Next.js 13+ makes it trivial to use via the Fonts API, which automatically optimises font loading, prevents layout shift, and self-hosts files so you don't rely on Google's CDN. This is the recommended way to use Geist in any Next.js project.
Yes. Import multiple fonts and combine their class names on <html>: `className={\`\${geist.className} \${geistMono.className}\`}`. Each gets its own CSS variable.
Yes, if you want to use `font-sans` and `font-mono` Tailwind classes. Add the CSS variables to your Tailwind config's `fontFamily` theme.
This free typescript code snippet for geist font in next.js is production-ready and copy-paste friendly. Whether you are building a web app, API, or frontend interface, this beginner-level example will help you implement geist font in next.js quickly and correctly.
All snippets in the Snippetly library follow typescript best practices and are tested for real-world use. You can adapt this code to work with React, Vue, Node.js, or any project that uses typescript.
Organise your team's code snippets with Snippetly. Share knowledge and boost productivity across your organisation.