Next.js Discord

Discord Forum

local fonts can't resolve

Answered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Avatar
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'
Image
Image
Answered by Ray
so you dont need to put them in the public folder
View full answer

9 Replies

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