You really use absolute import to improve the code reading and writing.
In today’s story, we will learn to import the modules from the absolute path. Instead of importing the packages, and components from the existing path, we will learn to import from the absolute path starting from the root directory.
Install nextjs in your current react application, I am assuming you have nextjs repository if not go to this link to download your first nextjs repository.
Create jsconfig.json file in the root directory, it’s easy once the project is created to add jsconfig.json file in the root directory.
Add the baseUrl key with the root path as the value in the config file. Just add the below code in the config file.
Start importing the components using baseUrl as the starting point.
Until next time, have a good day.