Next.js Discord

Discord Forum

Unable to import fonts using `@`

Answered
Anay-208 posted this in #help-forum
Open in Discord
I want to use the @ for importing fonts like this:
const monument = localFont({ src: '@/fonts/MonumentExtended-Regular.otf', variable: "--font-monument" })

however, I get an error: Module not found: Can't resolve './@/fonts/MonumentExtended-Regular.otf'
Why is it added ./ add the start of the path
Answered by joulev
the src string is simply a path string feeded to fs so you cant use absolute path import syntax here – it's simply not an import
View full answer

6 Replies

Answer
So what can I do of it? I need to use layout.tsx for a route, the problem is I’ll have it manually change the path for each.
You'll just have to update it manually
it's not like you're having 20+ files
maybe 3 or 4
I guess I'll do that. I dont really prefer hardcoding tho.