turborepo: [Turbopack] @Next/Font is not working properly with turbopack

What version of Turbopack are you using?

default from next 13

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Windows

Describe the Bug

@next/font isn’t working with the turbo pack properly. The turbo pack is throwing an error that @next/font/google failed to run or is incorrectly configured while I am importing it in my layout file in the app directory. Alongside the error, it is suggesting that I run the server without a turbo pack. I am trying to import the inter-font as per the documentation. The main reason for this issue is that turbo pack --turbo is running perfectly in all other scenarios if don’t use this library.

Expected Behavior

The font should load properly as it does without the turbo pack bundler compilation.

To Reproduce

  1. Install Next Js 13 using npx npx create-next-app app-name
  2. Create a new directory with the app name
  3. Add the layout.jsx file in the app directory
  4. Then, create the page.jsx file in app directory and create a basic react component
  5. Install @next/font library using node package manager npm install @next/font
  6. Import @next/font library in layout.jsx using import { Inter } from "@next/font/google"
  7. Initialize the font by creating the variable const inter = Inter()
  8. Finally change the HTML tag with this link <html lang="en" className={inter.className}>
  9. Run the server using npx next dev --turbo
  10. Open localhost:3000 in your browser.
  11. This error should be visible on the page
image

Reproduction Repo

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 19
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Still facing the same issue after updating to 14.0, local font not working

@timneutkens I just tested with Next 15 RC version and yes the font’s are working fine with Turbo!!!🎉

Experienced the same issue even on Windows, I think that is is because of font installation process, and if the issue persists, I may have to find alternatives. Hopefully, the issue of fonts with Turbopack can be resolved

@imran-prog Getting this error in Next 15 RC turbo, How to fix this?? image image

FYI all tests for next/font are now passing so this should work fine with Turbopack when using Next.js 15 (currently release candidate)

Hey y’all, we’re aware of this limitation. If you look very closely you’ll see that we throw an error message about this support. We look forward to bringing support for this very soon!

https://github.com/vercel/turbo/blob/4c5cab2755444fd60aa91aaba798473e58de117b/crates/turbopack/src/lib.rs#L66-L67

#2545 and #2494 are both reporting the same thing. At this point it’s not exactly a bug, more a known limitation, and internally we’re tracking toward implementing it. @wbinnssmith is the person currently investigating it. 🔜

In the mean time this is a possible workaround to enable using fonts with Turbopack: https://nextjs.org/docs/messages/no-page-custom-font#possible-ways-to-fix-it