Nextjs Tips Series: Absolute import and alias
Jan 11, 2021
--
NextJs has better support for absolute imports and aliases. It is now possible to set a baseUrl in jsconfig.json
. This file also has support for paths now.
// tsconfig.json or jsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/ui/*": ["components/*"]
}
}
}
// Imports 'components/ui/input'
import Input from '@/ui/input'
Thank you :)
You can get full access to every story on Medium for just $5/month by signing up through this link.