Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

What Is Next.js? React Routing, Rendering, and a First Page

Compare the App Router and Pages Router, choose how to render pages, and build a small Next.js route you can test locally.

Table of Contents

Next.js is a framework for building web applications with React. React provides the component model. Next.js adds file-based routing, rendering options, and server endpoints, so a project can define pages and some backend behavior together.

What is NextJS? All the basic knowledge you should know Picture 1

App Router and Pages Router use different conventions

  • App Router: A file such as app/about/page.tsx creates /about. Shared layouts use layout.tsx, and HTTP endpoints use route handler files such as app/api/hello/route.ts. App Router pages are Server Components by default. Use a Client Component for state, event handlers, or browser APIs.
  • Pages Router: A file such as pages/about.tsx creates the route. Existing projects may use getStaticProps, getServerSideProps, and pages/api. Follow documentation for the router your code actually uses.

What is NextJS? All the basic knowledge you should know Picture 2

Next.js builds on React and supplies the application structure around it.

Choose how to render each type of page

Stable public pages can be prerendered and cached. A page that depends on the current request or a signed-in user may need server rendering at request time. Interactive controls can still run in the browser. Decide when data should refresh, and verify that private content cannot be served from a shared cache. Server-rendered HTML can help crawlers discover content, but indexing also depends on access, metadata, and the content itself.

What is NextJS? All the basic knowledge you should know Picture 3

Routing, rendering, and image handling are among the features Next.js adds to React.

Create and verify your first route

Install a Node.js version supported by the Next.js release you’re using. In a terminal, create a project and select the App Router if prompted.

npx create-next-app@latest my-next-app
cd my-next-app
npm run dev

Open http://localhost:3000. Add the following as app/about/page.tsx, or src/app/about/page.tsx if you selected a src directory.

export default function AboutPage() {
  return <h1>About this project</h1>;
}

Visit http://localhost:3000/about and confirm the heading appears. Run npm run build before deploying. A static export supports a subset of features. Request-time rendering needs a compatible server or deployment platform. If components are new to you, start with the React Development course.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.