Next.js The Project, File by File
A fresh Next.js app holds a small set of files. Each file has one job, and this lesson names each one.
The top of the project
The listing shows eleven entries. The app folder and the public folder hold the app itself.
lsInside the app folder
Four files live in the app folder. The page file and the wrapper file are the two that matter most.
ls appInside the public folder
Five images live in the public folder. They are served as they are, with no code needed.
ls publicExample
console.log("app/ holds the pages.");
console.log("public/ holds the images.");
console.log("package.json lists the tools.");
console.log("next.config.ts holds the settings.");Key points
- app: the folder that holds the pages. Each page is a file inside it.
- page.tsx: the file that draws the home page. It is a React component.
- layout.tsx: the file that wraps every page. It holds the shared frame around each page.
- globals.css: the file that holds the styles for the whole app.
- public: the folder that holds images and files served as they are.
- package.json: the file that lists the app tools and the npm scripts.
In this example, four lines name the four parts of the project. The app folder holds the pages, and the public folder holds the images. The package.json file lists the tools, and the settings file holds the Next.js settings. Four lines is the whole map. Every file in the project belongs to one of these four parts.
Note
next.config.ts is the settings file for Next.js. You will not need to change it in this course.
Try it Yourself
Edit the code, then press Run.
Running is simulated · TypeScript Playground
Exercise
Which file draws the home page?