Next.js is a React framework for building web applications. This guide covers the main steps involved in starting a small project with the App Router.
Prerequisites
Before starting, install: - Node.js 18 or newer - Basic React knowledge - Familiarity with JavaScript or TypeScript
Create the Project
Use the Next.js project generator:
bashnpx create-next-app@latest my-first-app --typescript --tailwind --app
cd my-first-app
npm run devThe command creates a project with TypeScript, Tailwind CSS and the App Router.
The App Router
Folders inside `src/app/` represent routes. A `page.tsx` file supplies the page for that route. Layout files can hold UI that is shared between pages.
Server and Client Components
App Router components are Server Components by default. Add `"use client"` when a component needs browser interaction such as event handlers, state or effects.
Fetching Data
A Server Component can fetch data directly:
tsxasync function BlogPage() {
const posts = await fetch('https://api.example.com/posts');
return <div>{/* render posts */}</div>;
}Deploying
A Next.js project can be deployed by pushing it to GitHub and connecting the repository to Vercel. The platform detects the framework and runs the build for you.
What to Learn Next
Try dynamic routes, Server Actions, authentication middleware and image handling with next/image. Building a small project is the easiest way to understand how the pieces work together.