Sitemap
Karan Joura

Karan Joura

I am Senior Software Engineer with over 6+years of experience in full-stack software development. I have worked on various domains like telecom, e-commerce, etc

Next.Js Folder Structure

2 min readAug 21, 2022

Hello Dear Friends!

In my last story, I explained steps to do code setup of next.js project. Now, its important for us to know about the folder structure of next.js project.

The structure of next.js is bit different from react.js. Now you might be curious about difference between next.js and react.js.

Well! I will explain you each and every bit of it in my next story.

Get Karan Joura’s stories in your inbox

Join Medium for free to get updates from this writer.

In this story my main focus will be to make you aware about folder structure of Next.Js project.

So, Lets have a deep dive into the folder structure of next.js project.

In above snapshot, you can see the folder structure. Now, I will explain you about each part of this structure.

Folder Structure :

  • app-name : This represents the project name
  • components : It is same as components of react.js. To understand this, lets assume, there is a home page. In home page, there are multiple sections like header, side nav, footer. So, header, side nav & footer are components and will be treat them as a independent item so that where ever we embed it, it works, a sort of code re-usability.
  • pages : This is something new that we have never seen in angular & react.js. Any JavaScript file that we create in pages will be a direct link. Confused? No issues, for this moment, simply assume it as a direct link. We will also have a detailed discussion on this in upcoming story. I will attach its link soon.
  • static : Any static file like image, video, document,etc. are placed in this folder.
  • next.config.js: It is a regular Node.js module, not a JSON file. It gets used by the Next.js server and build phases, and it's not included in the browser build.
  • package.json: The package. json file is the heart of any Node project. It records important metadata about a project which is required before publishing to NPM, and also defines functional attributes of a project that npm uses to install dependencies, run scripts, and identify the entry point to our package.

I know, you might have confusion. But believe me when I will show you live examples, you will be expert.

So don’t loose hope. Believe in yourself !

Next we will learn about a very important topic of next.js that is Dynamic routing.

-Karan Joura

--

--

Karan Joura
Karan Joura

Written by Karan Joura

I am Senior Software Engineer with over 6+years of experience in full-stack software development. I have worked on various domains like telecom, e-commerce, etc