Next.js basics: rendering modes, a TypeScript starter app and deploying to Vercel

Next.js is a React framework from Vercel. On top of React it gives you file-based routing, server rendering and static generation, API endpoints, and a build pipeline, so you don’t have to wire those together yourself. This post was revised against Next.js 16.4 and React 19.
What Next.js gives you
Section titled “What Next.js gives you”- Server rendering and static generation. Pages can be rendered to HTML at build time or on each request instead of only in the browser.
- File-based routing.
app/about/page.tsxbecomes/about. Navigation withnext/linkhappens on the client without a full page reload. - Automatic code splitting. Each route only loads the JavaScript it needs.
- Route Handlers (the App Router’s version of API routes) for backend endpoints in the same project.
- Styling. CSS Modules, global CSS, Sass and Tailwind CSS work out of the box. CSS-in-JS libraries such as styled-components need extra setup, and only work in Client Components.
Why server rendering helps
Section titled “Why server rendering helps”With plain client-side React, the browser downloads an almost empty HTML file, then fetches and runs JavaScript before anything appears. With server-side rendering (SSR) or static generation, the HTML already contains the page content, so:
- The first paint doesn’t wait for your JavaScript bundle to download and run.
- Crawlers and link previews see real content without executing JavaScript.
- Content is readable even if JavaScript fails to load. Interactive parts (buttons, forms that use client state) still need JavaScript once the page hydrates.
In the App Router, components are Server Components by default and run only on the server. Add 'use client' at the top of a file when a component needs state, effects or browser APIs.
Create a TypeScript app
Section titled “Create a TypeScript app”npx create-next-app@latest my-appcd my-appnpm run devThe recommended defaults include TypeScript, ESLint, Tailwind CSS and the App Router. To be explicit, pass --ts --app. The generated tsconfig.json is already set up for Next.js, so you don’t need to edit it. The dev server runs at http://localhost:3000.
The home page lives in app/page.tsx. Replace it with:
import type { Metadata } from 'next';import Link from 'next/link';
export const metadata: Metadata = { title: 'My Next.js App', description: 'A small Next.js app',};
export default function Home() { return ( <main> <h1>Welcome to my Next.js app!</h1> <Link href="/about">About</Link> </main> );}app/layout.tsx, which create-next-app generates, wraps every page. Shared UI and global CSS imports go there.
A Route Handler is a route.ts file that exports functions named after HTTP methods:
// app/api/hello/route.ts -> GET /api/helloexport async function GET() { return Response.json({ message: 'Hello from Next.js' });}Built-ins worth using
Section titled “Built-ins worth using”- Data fetching. In the App Router, fetch data directly in an
asyncServer Component instead of usinggetStaticPropsorgetServerSideProps, which are Pages Router APIs. See the data fetching guide for caching options. - Metadata. Export a
metadataobject or agenerateMetadatafunction frompage.tsxorlayout.tsxfor titles and descriptions.next/headis Pages Router only. next/linkfor client-side navigation between routes.next/imagefor automatic resizing, modern formats and lazy loading of images.next/dynamicto lazy-load heavy client components that aren’t needed on first render.public/for static files served as-is from the site root.public/logo.pngis available at/logo.png.- CSS Modules (
*.module.css) for component-scoped class names.
Deploy to Vercel
Section titled “Deploy to Vercel”Vercel detects Next.js projects and builds them with no extra configuration.
- Push the project to GitHub, GitLab or Bitbucket.
- In the Vercel dashboard, go to vercel.com/new and import the repository.
- Check the detected settings (framework preset, build command, environment variables) and click Deploy.
Each push to the production branch then triggers a new deployment, and pull requests get preview URLs. You can add a custom domain in the project settings, and Vercel provisions the HTTPS certificate automatically.
To deploy from your machine without a Git repository, use the CLI:
npm i -g vercelvercelVercel isn’t required. next build && next start runs the app on any Node.js server, and Next.js can also produce a standalone build for Docker or a static export.
Further reading
Section titled “Further reading”© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)