Zero to Shipped

- Master Fullstack Development and finally ship a product

4 years ago

How to use the src directory and absolute imports in Next.js

#NextJS

#Dev

I'm super excited that this is finally a thing so all of my source code (src, get it) can live in the src directory and I can import it using absolute imports.

 
  • Make a tsconfig.json or jsconfig.json file
  • Add the baseUrl option:
{
"compilerOptions": {
"baseUrl": "./src"
}
}

That's it 🎉

 

If you're a WebStorm user make sure to right click the src directory and click "Mark as resource root".

 

More posts

The saddest "Just Ship It" story ever

GitHub stars won't pay your rent

GPT-3 is the beginning of the end

I made

🟣

Sizzy

The Browser For Developers

🐶

Benji

The life OS

🚢

Zero To Shipped

Interactive video course on mastering fast-paced Fullstack Development.