DEV Community

Alexander Kim
Alexander Kim

Posted on

3 2

Path aliases in Nextjs

Tired of writing such imports?

import test from '../../../components/Test.tsx';
Enter fullscreen mode Exit fullscreen mode

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

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@/*": ["./*"] 
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Then you can import more conveniently:

import test from '@/components/Test.tsx';
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more