Learnings

Tutorial 3 of 4

React vs Next.js

Only the places where Next changed or improved something you already do in React. Same task on both sides: plain React (Vite + React Router) on the left, Next (App Router) on the right. Things that are identical in both, such as props, state and hooks, are left out.

Project setup

React

What Next added: routing, Tailwind, linting and a server come preconfigured. In React you pick and wire each one.

Routing

React

What Next added: the folder structure is the route table. No router library, no central config file to keep in sync.

Dynamic routes

React

What Next added: the parameter arrives as a prop on the server, so you can use it to load data before any HTML is sent.

Shared layouts

React

What Next added: any folder can have its own layout.tsx, and layouts nest automatically. The layout also owns <html> and <body>, which React never touches.

Data fetching

React

What Next added: server components can be async. The data is fetched on the server and the browser receives ready HTML: no effect, no loading state, no empty first paint, and the API URL and keys stay private.

Loading and error states

React

What Next added: one file per route for each state. Under the hood these are React's own Suspense and error boundaries, set up for you.

Forms and saving data

React

What Next added: Server Actions. The form calls a server function directly, so you write no endpoint and no fetch, and revalidatePath refreshes the page data. React 19 defines <form action>; Next supplies the server side of it.

Auth and protected pages

React

The check runs in the browser, after the page code has already been downloaded.

What Next added: a server to do auth on. The token lives in an httpOnly cookie that browser scripts cannot read, and a logged out user never receives the protected page at all.

Backend endpoints

React

None. React runs only in the browser, so you need a separate backend (FastAPI, Express) and usually a dev proxy:

What Next added: route handlers. Frontend and small backend endpoints live in one project and deploy together. You can still call a separate backend from server code.

Images

React

What Next added: automatic resizing per screen size, modern formats (WebP, AVIF), lazy loading by default and reserved space so the layout does not jump.

Fonts

React

What Next added: the font is downloaded at build time and served from your own domain. No extra network request, no flash of a fallback font.

Page title and SEO

React

Set in the browser. A crawler that does not run JavaScript sees an empty page.

What Next added: a typed metadata API and server rendered HTML, so search engines and link previews get the real title, description and content.

Code splitting

React

What Next added: splitting per route by default, and server components ship no JavaScript at all.

Environment variables

React

Every value is visible in the browser bundle.

What Next added: real secrets. Variables without the NEXT_PUBLIC_ prefix never leave the server.

Where rendering happens

React

One mode: client side rendering.

What Next added: the server/client split ("use client"), faster first paint, and a choice of rendering mode for each page.

Build and deploy

React

Upload dist/ to any static host. Configure it to serve index.html for every path.

What Next added: a production server, which is what makes everything above possible. The cost is that hosting is no longer a folder of files.

Which one to pick

Plain React fits when

  • The app sits behind a login and SEO does not matter (internal tools, admin panels).
  • You already have a backend API and want a static frontend.
  • You want the smallest set of concepts to learn first.

Remember: everything from the React tutorial still applies inside Next. Next changes where code runs and how pages are wired, not how components work.