Next.js Zero to Advanced #1: Introduction & Project Setup
Welcome to the Next.js Zero to Advanced series! Across 12 parts we will build one complete application called DigiStore: a small digital-product store where sellers list e-books, source code and templates, visitors browse and "buy", and an admin manages the products. Every part continues the same codebase, so by the end of the series you will have one complete full-stack project: from the first page, a PostgreSQL database with Prisma, forms with Server Actions, a REST API and authentication, all the way to a production deployment.
This series is for you if you already understand basic HTML, CSS and JavaScript (for example from our JavaScript Zero to Advanced series on FullstackNotes) but are new to React and Next.js. In Part 1 we will not write much code yet. The focus is understanding what Next.js is, preparing your tools, creating the project and getting to know its folder structure.
What Is Next.js?
Next.js is a framework for building web applications with React. If React is the "engine" that builds user interfaces out of components, Next.js is the "complete car": routing, server rendering, image and font optimization, bundling and even a way to build APIs are provided and wired together.
React vs Next.js
React on its own is just a UI library. With plain React you still have to choose and assemble many pieces yourself: a routing library, a data-fetching strategy, server rendering for good SEO, bundler configuration and so on. Next.js makes those decisions for you using proven patterns.
| Need | Plain React | Next.js |
|---|---|---|
| Routing (URL to page) | Install an extra library | Built in, folder-based (file-based routing) |
| Server rendering | Fairly complex manual setup | Built in, the default through Server Components |
| Reading data from a database | Needs a separate backend | Directly in Server Components, Server Actions or Route Handlers |
| Image & font optimization | Manual | The next/image and next/font components |
| Build & deploy | Configure your own bundler | One command: next build |
That is why Next.js is often called a full-stack framework: one project can contain the user interface (frontend) as well as server logic (backend).
The App Router
Next.js has two routing systems: the Pages Router (older, the pages/ folder) and the App Router (modern, the app/ folder). This series uses the App Router exclusively, which is the officially recommended approach. In the App Router, the folder structure inside app/ becomes your URLs. For example, the file app/products/page.tsx is shown at /products. We cover this in detail in Part 2.
The App Router is also built on React Server Components: by default, components are rendered on the server and only their HTML is sent to the browser. Components that need interactivity (clicks, state) are marked as Client Components. This important concept gets its own part, Part 3.
Versions we use
- Next.js 16 with React 19 and TypeScript.
- Node.js 20.9 or newer (the minimum version required by Next.js 16).
- Later on: PostgreSQL 16 (Part 5) and Prisma 6 (Part 6).
Next.js 16 has several big changes compared with older versions. For example,
paramson dynamic pages is now a Promise, andmiddleware.tshas been renamed toproxy.ts. If you read older tutorials elsewhere, watch out for these differences. All code in this series targets Next.js 16.
Preparing Your Tools
1. Installing Node.js
Next.js runs on Node.js. Download the LTS version from nodejs.org and install it like any other application. macOS/Linux users who want to switch between Node versions can also use a version manager such as nvm. Once installed, open a terminal and check the versions:
node -v
npm -v
Result:
v22.11.0
10.9.0
Your exact numbers may differ. What matters is that Node is at least 20.9. npm (Node Package Manager) is installed together with Node and is used to install packages.
2. A code editor
We recommend Visual Studio Code. Its TypeScript support is excellent, so you get autocomplete and error warnings while you type. The ESLint and Tailwind CSS IntelliSense extensions are very helpful too.
Creating the DigiStore Project
Running create-next-app
The quickest way to start a Next.js project is create-next-app. Open a terminal in the folder where you usually keep your projects and run:
npx create-next-app@16 digistore
npx runs a package without installing it globally, and @16 makes sure we use Next.js version 16 like the rest of this series. digistore is the project folder name (use lowercase letters, because npm package names cannot contain capitals).
You will be asked a few questions. They look roughly like this (order and wording may differ slightly between minor versions):
What is your project named? digistore
Would you like to use the recommended Next.js defaults?
Yes, use recommended defaults - TypeScript, ESLint, No React Compiler, Tailwind CSS, No src/ directory, App Router, Cache Components, AGENTS.md
No, reuse previous settings
No, customize settings - Choose your own preferences
Choose Yes, use recommended defaults. These defaults are exactly what we need:
- TypeScript: JavaScript with types, which helps catch mistakes earlier.
- ESLint: a code-quality checker (
npm run lint). - Tailwind CSS: styling with utility classes, covered in depth in Part 4.
- No
src/folder: theapp/folder sits directly in the project root. - App Router and the
@/*import alias: we can writeimport ... from '@/lib/products'from anywhere. - Cache Components: the new caching model in Next.js 16. For now it is enough to know it is enabled; we discuss caching in Part 7.
- AGENTS.md: a guide file that helps AI coding assistants write up-to-date Next.js code. It is safe to keep.
If you choose customize settings instead, make sure your answers match the list above: TypeScript Yes, linter ESLint, React Compiler No, Tailwind CSS Yes, src/ No, App Router Yes, and the default import alias @/*.
create-next-app then downloads the dependencies. Wait for the success message, then move into the project folder:
cd digistore
A Tour of the Folder Structure
Open the digistore folder in VS Code (code . if that command is installed). The structure looks roughly like this:
digistore/
βββ app/
β βββ favicon.ico
β βββ globals.css
β βββ layout.tsx
β βββ page.tsx
βββ public/
β βββ (a few .svg files)
βββ node_modules/
βββ .gitignore
βββ AGENTS.md
βββ eslint.config.mjs
βββ next-env.d.ts
βββ next.config.ts
βββ package.json
βββ postcss.config.mjs
βββ README.md
βββ tsconfig.json
The app/ folder
This is the heart of the App Router. Every folder inside app/ is a URL segment, and files with special names have specific roles:
app/layout.tsxis the root layout: the frame that wraps every page (it is required and must contain the<html>and<body>tags).app/page.tsxis the page for the/URL (the home page).app/globals.cssholds global CSS, including the Tailwind import.app/favicon.icois the browser tab icon.
The public/ folder
Static files such as images or robots.txt go here and are served directly from the root URL. For example, public/logo.svg is available at /logo.svg.
Configuration files
| File | Purpose |
|---|---|
package.json | Dependencies and scripts (dev, build, start, lint). |
next.config.ts | Next.js configuration (for example Cache Components, image domains in Part 4, security headers in Part 11). |
tsconfig.json | TypeScript configuration, including the @/* alias. |
eslint.config.mjs | ESLint rules. |
postcss.config.mjs | Connects Tailwind CSS to the build. |
next-env.d.ts | Type declarations generated by Next.js. Do not edit it. |
.gitignore | Files Git should ignore, including node_modules and .env* files. |
Open next.config.ts. Because we chose the recommended defaults, it contains roughly:
// next.config.ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
cacheComponents: true,
partialPrefetching: true,
}
export default nextConfig
Leave it as it is for now. Next, look at the scripts section in package.json:
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
}
}
npm run dev: starts the development server with hot reload.npm run build: creates an optimized production build.npm run start: runs the production build.npm run lint: checks your code with ESLint.
Running the Development Server
From inside the digistore folder, run:
npm run dev
Result (roughly):
β² Next.js 16.x (Turbopack)
- Local: http://localhost:3000
β Ready in 1.2s
Open http://localhost:3000 in your browser. You will see the default Next.js welcome page. Congratulations, your first Next.js app is running! By default Next.js 16 uses Turbopack as its bundler, so startup and reloads feel fast.
Keep this terminal open while you work. To stop the server, press Ctrl + C.
First Edit: The DigiStore Home Page
Replacing app/page.tsx
Open app/page.tsx, delete everything in it, and replace it with the following code:
// app/page.tsx
export default function HomePage() {
return (
<main className="mx-auto max-w-3xl p-8">
<h1 className="text-3xl font-bold">Selamat datang di DigiStore</h1>
<p className="mt-4 text-lg">
Toko produk digital: e-book, source code, dan template siap pakai.
</p>
<p className="mt-2 text-gray-600">
Proyek ini kita bangun bertahap di seri Next.js dari Nol hingga Mahir.
</p>
</main>
)
}
We keep the UI text in Indonesian because DigiStore is an Indonesian store. Save the file and look at the browser. The page updates immediately without a manual refresh. This feature is called Fast Refresh.
Result: a large "Selamat datang di DigiStore" heading with two paragraphs below it.
Understanding the code
- A page is a
page.tsxfile that default-exports a React component. The function name (HomePage) is up to you, butexport defaultis required. - What it returns is JSX: HTML-like syntax inside JavaScript. One small difference: the
classattribute is writtenclassName. - Classes like
text-3xlandfont-boldare Tailwind CSS utility classes. Details in Part 4. - This component is a Server Component: it is rendered on the server and its HTML is sent to the browser. We cover this in Part 3.
Changing the document language
Since DigiStore is in Indonesian, open app/layout.tsx and change <html lang="en"> to <html lang="id">. Leave the rest of that file alone for now. The lang attribute helps screen readers and search engines understand the page language.
Saving Progress with Git
create-next-app automatically initializes a Git repository and makes a first commit. Save your changes:
git add .
git commit -m "Part 1: halaman beranda DigiStore"
Notice that the default .gitignore already excludes node_modules and .env* files. This matters: in Part 5 we will store the database connection in .env, and files containing secrets like that must never be committed to Git.
Common Mistakes
- Node version too old. If you get errors from
create-next-appornpm run dev, checknode -v. Next.js 16 needs at least Node 20.9. - Running commands in the wrong folder.
npm run devmust be run inside thedigistorefolder (the one containingpackage.json). - Port 3000 already in use. Next.js will offer another port (such as 3001). Read the URL printed in the terminal, or stop the other app using port 3000.
- Forgetting
export default. Without a default export, Next.js does not know which component is the page and shows an error. - Following outdated tutorials. Examples that use a
pages/folder,getServerSideProps, orparamswithoutawaitcome from older versions and do not match this series. - Using
classinstead ofclassName. In JSX, useclassName.
Exercises
- Add a third paragraph to the home page that lists DigiStore's three product categories, E-book, Source Code and Template, as a
<ul>list. - Run
npm run lintand make sure there are no errors. Then deliberately writeclasson one element and watch the warning appear in your editor. - Put an image file (for example
logo.svg) in thepublic/folder, then openhttp://localhost:3000/logo.svgin the browser to prove static files are served directly.
Summary
- Next.js is a full-stack framework on top of React that bundles routing, server rendering, optimizations and APIs in one package.
- This series uses the App Router: folders inside
app/become URLs, andpage.tsxbecomes a page. - We installed Node.js 20.9+ and created the project with
npx create-next-app@16 digistoreusing the recommended defaults (TypeScript, ESLint, Tailwind CSS, App Router, nosrc/,@/*alias). npm run devruns the app athttp://localhost:3000with Fast Refresh.- We replaced
app/page.tsxwith the DigiStore home page and changed the document language toid.
In Part 2 we start building real pages: a product list, a product detail page with a dynamic URL, a shared layout with navigation, plus "not found" and loading screens. See you there!
Related articles
PostgreSQL Zero to Advanced #1: Introduction & Setup
Start the series by understanding what a relational database is, installing PostgreSQL locally, and getting comfortable with psql commands like \l, \c and \dt.
PHP Zero to Advanced #1: Introduction & Setup
Start your PHP journey: what PHP is, how to install PHP 8.2+, run the built-in development server, and write your very first script with echo.
Ruby on Rails Zero to Advanced #1: Ruby Basics
Start the Rails journey with the language underneath it: irb, variables, strings, puts vs p, and symbols explained with runnable examples.