45 Mins

1. Introduction to Next.js 15

Introduction

Welcome to Next.js 15!

If you already know React, you might be asking yourself: "Why do I need another framework? Isn't React enough?" It's a fair question, and by the end of this lesson you'll understand exactly why the answer is almost always yes, you need Next.js — and what it actually gives you.

Think of React as a box of high-quality car parts: an engine, tires, seats, a steering wheel. Excellent parts, but you still have to build the car yourself. You have to wire up routing, decide how pages load, configure a build tool, set up a server, and figure out how to keep secrets like API keys off the browser.

Next.js is the fully assembled vehicle. It takes React's parts and bolts them together with a file-based routing system, built-in server rendering, automatic code-splitting, image and font optimization, and a production-ready build pipeline. You get in and drive — spending your time on your app's logic instead of its plumbing.

This first module is your on-ramp. We won"t touch advanced patterns yet — that"s what the rest of this course is for. Here, you'll understand why Next.js exists, install it correctly, and get a real app running on your machine for the first time.

What Problem Does Next.js Actually Solve?

Every React app eventually needs to answer the same set of questions: How do I navigate between pages? Where should my data fetching happen? How do I make my site show up properly on Google? How do I make the very first page load fast, instead of showing a blank screen while JavaScript downloads?

Plain React (for example, a project started with Vite) doesn"t answer any of these for you. It"s a UI library, not a full application framework — it renders components, and that's it. Everything else, you assemble yourself by installing and configuring separate libraries.

Next.js was built by the same people who help maintain React, with the explicit goal of answering those questions out of the box. It"s what"s known as a meta-framework: a framework built on top of another framework, adding the missing structural pieces.

React (TSX)
// Next.js solves routing automatically with folders
// app/dashboard/page.tsx -> /dashboard
export default function Dashboard() {
  return <h1>Dashboard</h1>;
}

React vs. Next.js: A Side-by-Side Look

Here's how a traditional React app compares to a Next.js app across the things that matter most in a real project:

Feature Traditional React (Vite) Next.js 15 (App Router)
Routing Install react-router-dom and write your own route configuration. Automatic routing. Creating a folder inside app/ creates a route.
Rendering Client-side only. The browser downloads JS, then builds the whole page. Server-side by default. HTML is ready before it reaches the browser.
SEO Poor out of the box. Crawlers often see an empty <div id=<strong><code>root>. Strong by default. Fully rendered HTML and metadata ship with every page.
Backend / API You need a separate backend project (Node, Python, etc.). Full-stack. API routes live right beside your pages.
Optimization Manual — you configure image compression, code-splitting, fonts yourself. Automatic. Images, fonts, and scripts are optimized without extra setup.
React (TSX)
// React (Manual Setup)
import { BrowserRouter, Route, Routes } from 'react-router-dom';
function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/about" element={<About />} />
      </Routes>
    </BrowserRouter>
  );
}

// Next.js (Zero Setup)
// Just create app/about/page.tsx
export default function About() {
  return <h1>About</h1>;
}

The Big Mental Shift: Server vs. Client

This is the single most important idea in this entire course, so it"s worth introducing early — we"ll go much deeper in the next module. In a normal React app, 100% of your component code ends up in the browser. That's a problem if you want to query a database or use a secret API key, because anything shipped to the browser can be read by anyone.

Next.js solves this by splitting your app into two environments that work together:

  • The Server: Components run here by default. They can talk to databases, read files, and use secret keys safely — none of that code is ever sent to the browser.
  • The Client: Anything that needs interactivity — a button click, a form, a hook like useState — runs in the browser, and is marked explicitly with a <strong><code>use client directive at the top of the file.
Quick Check: By default, every component you create in the App Router is a Server Component. You only opt into the browser environment when you actually need it.
React (TSX)
// Server Component (Runs on server, sends HTML)
export default async function ServerSide() {
  const data = await db.query();
  return <div>{data}</div>;
}

// Client Component (Runs in browser, has interactivity)
'use client';
export default function ClientSide() {
  return <button onClick={() => alert('Clicked!')}>Click Me</button>;
}

Before You Install: Prerequisites

Next.js is a Node.js-based tool, so you'll need Node installed on your machine before anything else. You can check whether you already have it, and which version, by running:

Bash
node -v

Next.js 15 requires Node.js 18.17 or later. If you don't have Node installed, or your version is older, download the latest LTS release from nodejs.org and install it before continuing. You'll also want a code editor (VS Code is the most common choice) and basic comfort with the terminal — running commands and navigating folders.

Creating Your First App

With Node ready, creating a new Next.js project takes a single command. Open your terminal, navigate to where you want your project to live, and run:

Bash
npx create-next-app@latest my-app

The installer will walk you through a short setup wizard, asking about TypeScript, ESLint, Tailwind CSS, and more. For the best modern defaults — and to match what this course uses — choose Yes to TypeScript, Tailwind CSS, and the App Router.

Terminal Prompts Would you like to use TypeScript? Yes Would you like to use ESLint? Yes Would you like to use Tailwind CSS? Yes Would you like to use the app/ directory? Yes

Once it finishes, create-next-app has generated a complete, working project for you — dependencies installed, folders scaffolded, and sensible defaults configured. No manual wiring required.

Your First Page Component

In the App Router, pages aren"t registered anywhere — they"re defined purely by the files you create. A file named page.tsx inside the app/ directory automatically becomes a route. The one at the very top level becomes your homepage:

React (TSX)
// app/page.tsx
export default function HomePage() {
  return (
    <div style={{ padding: '24px' }}>
      <h1>Welcome to Next.js!</h1>
      <p>Next.js automatically renders this component as the homepage.</p>
    </div>
  );
}
Visual Result A simple webpage with a heading and description, rendering instantly at the root URL.

There's no import to register, no route config to update. Create the file in the right place, and Next.js takes care of the rest. We'll explore this file-based routing system in full detail in the next module.

Running the Dev Server

Once your project is created, move into the folder and start the local development server:

Bash
cd my-app
npm run dev
Terminal Output ▲ Next.js 15.0.0 - Local: http://localhost:3000 Ready in 1.2s

Open http://localhost:3000 in your browser and you'll see your app running live. Try editing the text in app/page.tsx and saving the file — Next.js's Fast Refresh updates the page in the browser almost instantly, without a full reload and without losing your app's current state.

Quick Check: Fast Refresh is a development-only feature. In production, your app is compiled into optimized, static output — there's no live-reloading involved.

Where You're Headed

You now understand what Next.js is, why it exists, and you have a real project running on your machine. That's the entire foundation this course builds on. In the next module, we'll open up the app/ directory properly and learn exactly how routing, layouts, and special files work together — the system that makes all of this automatic magic possible.

Deep Dive Reference: Next.js Fundamentals

Edge Cases & Rendering Nuances

The distinction between Client and Server Rendering has profound implications. If you use a third-party library that references window (like a charting library) inside a default Server Component, it will fail at build time.

Rules of thumb for Next.js 15:

  • Data fetching, DB access, and backend secrets MUST remain on the Server.
  • Event listeners (onClick), React Hooks (useState, useEffect), and Browser APIs MUST run on the Client.
  • By default, EVERYTHING is a Server Component. You must explicitly opt-in to the client using 'use client'.

Knowledge Check

Ready to test your understanding of 1. Introduction to Next.js 15?

Back