0

I want to import my pages, components, and containers directly like 'components/filename' OR '@components/filename' instead of specifying the path to the parent folder like '../../components/filename'

How can I achieve that in React JS or Next JS with Typescript?

2 Answers2

1

from next.js docs: https://nextjs.org/docs/advanced-features/module-path-aliases here is the example from project:

enter image description here

0

i think you need to check the .jsconfig of your project, follow this article to learn about it : https://dev.to/rfornal/create-path-aliases-in-react-2oid

also check this article : https://medium.com/hackernoon/absolute-imports-with-create-react-app-4c6cfb66c35d

coderpolo
  • 307
  • 3
  • 12