Next.js Discord

Discord Forum

local fonts can't resolve

Answered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
I don't get how to type a correct path for local fonts. They are in the 'public/fonts'. It can resolve if fonts are in the same folder as layout.tsx, plus it can be resolved if path would be: '../public/fonts/myFont.woff2'. But I dont understand why I cant get them with default public path, like: '/fonts/myFont.woff2' or at least '@/public/fonts/myFont.woff2'
Answered by Ray
so you dont need to put them in the public folder
View full answer

9 Replies

@Ray try changing the path to `/public/fonts/xxxx`
Saltwater CrocodileOP
@Saltwater Crocodile Click to see attachment
oh should be ../public/fonts/xxx
@Ray oh should be `../public/fonts/xxx`
Saltwater CrocodileOP
yea, it works if I set by default way, but i dont understand why it doesnt work like static asset public folder
@Saltwater Crocodile yea, it works if I set by default way, but i dont understand why it doesnt work like static asset public folder
because it is expecting the relative path of the font and will copy the font to static assets folder when building
so you dont need to put them in the public folder
Answer
@Ray so you dont need to put them in the public folder
Saltwater CrocodileOP
thank you man for explanation. now i get it