Path aliases in Nextjs

Published 
React

Tired of writing such imports?

import test from '../../../components/Test.tsx'

If you're using a typescript, you can create a path alias instead:

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@/*": ["./*"]
    }
  }
}

Then you can import more conveniently:

import test from '@/components/Test.tsx'

Don't forget to restart your running task to affect changes.