Gathering detailed insights and metrics for next-google-fonts
Gathering detailed insights and metrics for next-google-fonts
Gathering detailed insights and metrics for next-google-fonts
Gathering detailed insights and metrics for next-google-fonts
next-google-fonts-loader
[npm]: https://www.npmjs.com/package/next-google-fonts-loader
next-google-fonts-helper
Little component for loading Google fonts fast in Next.js
astro-font
An Astro integration to optimize Local & Google fonts inspired by @next/font
nextjs-google-fonts
Plugin for next.js
A tiny Next.js helper for loading Google Fonts fast and asynchronously ⏩
npm install next-google-fonts
Typescript
Module System
Node Version
NPM Version
27.3
Supply Chain
70.3
Quality
75.6
Maintenance
100
Vulnerability
91.4
License
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
425 Stars
191 Commits
6 Forks
3 Watchers
1 Branches
3 Contributors
Updated on Jun 23, 2025
Latest Version
2.2.0
Package Id
next-google-fonts@2.2.0
Size
6.10 kB
NPM Version
6.14.4
Node Version
13.12.0
Published on
Mar 30, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A tiny next/head
helper for loading Google Fonts fast and asynchronously ⏩
Using Next.js 10? See "How does this compare to Next.js font optimization?" before continuing.
In this example, we're going to add Inter
(specifically weights 400
and 700
) to a Next.js app.
See joebell.co.uk for a working example.
Add the package to your Next.js project:
1npm i next-google-fonts
Create a custom Head
component.
It's important to acknowledge that next-google-fonts
is a small next/head
component and should not be nested inside next/head
. To solve this, wrap both components with a Fragment
.
1// components/head.js 2import * as React from "react"; 3import NextHead from "next/head"; 4import { GoogleFonts } from "next-google-fonts"; 5 6export const Head = ({ children, title }) => ( 7 <React.Fragment> 8 <GoogleFonts href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" /> 9 <NextHead> 10 <meta charSet="UTF-8" /> 11 <meta 12 name="viewport" 13 content="width=device-width, initial-scale=1.0" 14 /> 15 <meta httpEquiv="x-ua-compatible" content="ie=edge" /> 16 17 <title>{title}</title> 18 19 {children} 20 </NextHead> 21 </React.Fragment> 22);
Add the requested Google Font/s to your styles with a sensible fallback. It really doesn't matter whether you're using CSS or Sass or CSS-in-JS:
1body { 2 font-family: "Inter", sans-serif; 3}
Run your Next.js app to see the results in action!
You should expect to see the fallback font first, followed by a switch to the Google Font/s without any render-blocking CSS warnings. Your font/s will continue to display until your app is re-hydrated.
If JS is disabled, only the fallback font will display.
Next.js 10 introduced automatic Google Font optimization, you can make a decision on which solution to use based on the following criteria:
next-google-fonts
.Next.js
font optimization.For further reading, see the Next.js issue discussion.
next-google-fonts
aims to make the process of using Google Fonts in Next.js more consistent, faster and painless: it preconnects to font assets, preloads and asynchronously loads the CSS file.
In the current iteration of next/head
, we can't make use of the familiar "media hack" method of asynchronous Google font loading:
1<!-- Plain HTML --> 2<link 3 rel="stylesheet" 4 href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" 5 media="print" 6 onload="this.media='all'" 7/>
If you'd like to track this issue in Next.js, you can follow it here: Next.js#12984.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
49 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More