mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
6e3af1b0fe
Closes: https://linear.app/vercel/issue/DOC-4641/fonts Redirects: https://github.com/vercel/front/pull/45242
28 lines
1011 B
Plaintext
28 lines
1011 B
Plaintext
---
|
|
title: Google Font Preconnect
|
|
---
|
|
|
|
> **Note**: Next.js automatically adds `<link rel="preconnect" />` after version `12.0.1`.
|
|
|
|
> Ensure `preconnect` is used with Google Fonts.
|
|
|
|
## Why This Error Occurred
|
|
|
|
A preconnect resource hint was not used with a request to the Google Fonts domain. Adding `preconnect` is recommended to initiate an early connection to the origin.
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
Add `rel="preconnect"` to the Google Font domain `<link>` tag:
|
|
|
|
```jsx filename="pages/_document.js"
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
|
```
|
|
|
|
> **Note**: a **separate** link with `dns-prefetch` can be used as a fallback for browsers that don't support `preconnect` although this is not required.
|
|
|
|
## Useful Links
|
|
|
|
- [Preconnect to required origins](https://web.dev/uses-rel-preconnect/)
|
|
- [Preconnect and dns-prefetch](https://web.dev/preconnect-and-dns-prefetch/#resolve-domain-name-early-with-reldns-prefetch)
|
|
- [Next.js Font Optimization](/docs/pages/api-reference/components/font)
|