question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Font Optimization is not fully working

See original GitHub issue

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000
    Binaries:
      Node: 17.8.0
      npm: 8.5.5
      Yarn: 1.22.18
      pnpm: N/A
    Relevant packages:
      next: 12.1.4
      react: 18.0.0
      react-dom: 18.0.0

What browser are you using? (if relevant)

Chrome 100.0.4896.60

How are you deploying your application? (if relevant)

Vercel, Heroku

Describe the Bug

Font Optimization is not working fully.

This happened after upgrading to React@18.

I have set up the project and using _document.tsx would like to add some of Google Fonts.

This is what it looks like in _document.tsx. CleanShot 2022-04-02 at 17 07 48@2x

This is what it should look like after deployment. CleanShot 2022-04-02 at 17 09 31@2x

However, this is what it looks currently like after deployment. CleanShot 2022-04-02 at 17 10 30@2x

The href is turned to data-href after font optimization. But, link is not turned to style.

Expected Behavior

Font Optimization should work.

To Reproduce

Since it appears in individual projects, it is normal in most cases. So it’s hard to reproduce. I tried, but I can’t reproduce it by creating a new project.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:11
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
firatciftcicommented, Apr 3, 2022

I am also experiencing the same issue. This problem started after upgrading my project to React 18.0.0.

4reactions
okisdevcommented, May 13, 2022

Hi @huozhi

I can confirm that this issue has been resolved in next@12.1.7-canary.5.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

First impressions on Next.js Automatic Font Optimization
Despite the name, currently it only works for Google Fonts loaded from fonts.googleapis.com . It does not work with other sources, including eg....
Read more >
Optimize WebFont loading and rendering - web.dev
This post explains how to load WebFonts to prevent layout shifts and blank pages when WebFonts are not available when the page loads....
Read more >
A Guide to Web Font Optimization
Learn how to better optimize the delivery of your fonts in this comprehensive, hands-on guide.
Read more >
8 Font Loading Strategies to Improve Your Core Web Vitals ...
Find the best font loading techniques to optimize your site's performance and pass your Core Web Vitals. Apply them manually or using ...
Read more >
How to use Font Optimization in Nextjs 13?
It does not work with other font providers. If you use any other font, ... You can use any google font in nextjs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found