Configuration: Absolute imports in Next.js

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


Wouldn’t it be great if we could avoid relative paths in imports, in our React components in Next.js?

So instead of for example:

import Layout from '../../components/layout'

We could just write:

import Layout from 'components/layout'

This is possible, and it’s called absolute imports.

Just add a file named jsconfig.json in the root of your project with this content:

{
  "compilerOptions": {
    "baseUrl": "."
  }
}

That’s it, absolute imports will start working.

Lessons in this unit:

0: Introduction
1: ▶︎ Absolute imports in Next.js
2: How to change a Next.js app port
3: Next.js, adding features just to development mode
4: Next.js how to show something in development and hide in production
5: Adding a wrapper component to your Next.js app