Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 18, 2021 05:31 am GMT

Path aliases in Nextjs

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.


Original Link: https://dev.to/avxkim/path-aliases-in-nextjs-4pio

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To