fix: resolve next/font/local loading issues#81
Merged
valentinpalkovic merged 2 commits intoDec 12, 2025
Merged
Conversation
The @fs URL prefix was concatenated directly with the font file path, creating invalid URLS like `/@fsc:/path` insted of `/@fs/C:path`. Additionally, the src property was missing a semicolon, causing CSS parsing errors and preventing font requests from being made. This caused 404 errors and font loading failures in dev mode.
- Add top-level weight and style to @font-face when src is a string - Exclude variable font weight ranges from className (only static weights) - Align with Next.js localFont behavior
valentinpalkovic
approved these changes
Dec 10, 2025
valentinpalkovic
approved these changes
Dec 12, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, @valentinpalkovic !
I've applied the same fix from #32998 to the Vite plugin and discovered additional bugs that needed to be addressed.
Summary
This PR fixes two critical bugs that prevented local fonts from loading correctly in development mode with
next/font/local.Changes
1. Fix: Support top-level weight/style in next/font/local with string src
2. Fix @fs URL formatting and CSS syntax in @font-face (new bug) ✨
Commit: fix: add slash separator and semicolon in @font-face CSS
Issues Fixed:
Missing slash between
@fsprefix and font path/@fsC:/path/to/font.woff2→ 404 error/@fs/C:/path/to/font.woff2→ 200 (works correctly)Missing semicolon after
srcproperty in@font-faceruleFiles Changed:
src/plugins/next-font/local/get-font-face-declarations.tsBefore:
After:
Test Result for second issue
💡 1. load font with next font local like under:
❌ before add
/after@fs✅ after add
/after@fs💡 2. load font with next font local like under:
❌ before add
;after src value & add/after@fs✅ after add
;after src value & add/after@fs