Skip to content

useGoogleFontPreconnect

Ensure the preconnect attribute is used when using Google Fonts.

When using Google Fonts, adding the rel="preconnect" attribute to the <link> tag that points to https://fonts.gstatic.com is recommended to initiate an early connection to the font’s origin. This improves page load performance by reducing latency.

Failing to use preconnect may result in slower font loading times, affecting user experience.

Note: Next.js automatically adds this preconnect link starting from version 12.0.1, but in cases where it’s manually added, this rule ensures the preconnect attribute is properly used.

<link href="https://fonts.gstatic.com"/>
code-block.jsx:1:1 lint/nursery/useGoogleFontPreconnect  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The attribute rel=“preconnect” is missing from the Google Font.

> 1 │ <link href=“https://fonts.gstatic.com&quot;/>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Not using preconnect can cause slower font loading and increase latency.

Safe fix: Add the rel=“preconnect” attribute.

1 │ <link·href=“https://fonts.gstatic.com·rel=preconnect/>
+++++++++++++++++
<link rel="preload" href="https://fonts.gstatic.com"/>
code-block.jsx:1:1 lint/nursery/useGoogleFontPreconnect ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The attribute rel=“preconnect” is missing from the Google Font.

> 1 │ <link rel=“preload” href=“https://fonts.gstatic.com&quot;/>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Not using preconnect can cause slower font loading and increase latency.

<link rel="preconnect" href="https://fonts.gstatic.com"/>
<link href="/logo.svg" rel="icon" />
biome.json
{
"linter": {
"rules": {
"nursery": {
"useGoogleFontPreconnect": "error"
}
}
}
}