Skip to content

Instantly share code, notes, and snippets.

@dipanshuchaubey
Created July 18, 2022 08:11
Show Gist options
  • Save dipanshuchaubey/6036305fb7ffef3ec616cb7b293b502e to your computer and use it in GitHub Desktop.
Save dipanshuchaubey/6036305fb7ffef3ec616cb7b293b502e to your computer and use it in GitHub Desktop.
How to add alias in `Next.js` imports

Add Alias in Next.js Imports

Update your tsconfig.json or jsconfig.json

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

Now, restart you TS server

On Mac Cmd+Shift+P > Typescript: Restart TS Server

On PC Ctrl+Shift+P > Typescript: Restart TS Server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment