Is Next.js frontend or backend?
Next.js builds the pages people see, and it also runs your server code: Server Components, Server Actions, and Route Handlers. Here's which parts run where, and when a separate backend still makes sense.

Think of a hotel's front desk. Guests never walk into the kitchen or the laundry. They ask the desk, and the desk calls whoever can help, puts the answers together, and hands the guest one reply. The desk isn't the kitchen, but it's a lot more than a counter.
Next.js is both frontend and backend. It's a React framework for building the pages people see, and it also runs your server code: Server Components, Server Actions, and Route Handlers live in the same project as your pages. That makes it a full-stack framework and a good backend for its own frontend. Its docs say plainly, though, that it isn't a full backend replacement.
Which parts of a Next.js app run in the browser?
The interactive parts. A file that starts with "use client" marks where the browser side begins: its components, and whatever that file imports, are Client Components. That's where state, click handlers, and Effects live, because they need a browser to run in.
Client Components still get their HTML made on the server. Then React, in the browser, matches them to that HTML and attaches their event handlers. That step is called hydration, and it's when the buttons start to work. After that, Next.js's router handles navigation in the browser: a <Link> click brings only what the next page needs, instead of a whole new document, and the router may already have it from prefetching. Client Components and a first look at how Next.js works show each step with a recorded app.
Which parts run on the server?
Everything else. Components start as Server Components, and a few other pieces only ever run on the server:
| Piece | What it does | Who calls it |
|---|---|---|
| Server Components | Render the page, and can read a database or a secret key directly. Their code never reaches the browser | Next.js, when it renders a page |
| Server Actions | Functions marked "use server" that change data, like saving a review |
Your own forms and buttons |
| Route Handlers | route.ts files that answer HTTP requests with JSON, files, or streams |
Other programs: a phone app, a partner's site, a webhook |
proxy.ts |
Runs before a route, to redirect, rewrite, or set headers and cookies | Next.js, for each request it matches |
after() |
Runs work once the response has gone out, like logging | Next.js, after the answer |

Server Components, Server Actions, and Route Handlers each have a lesson of their own.
Do your own pages need an API?
No. In a client-rendered React app, the browser can't reach your database, so you build an API for it and fetch from it. In Next.js, a Server Component calls your data function directly:
// app/teas/page.tsx
import { getTeas } from "@/lib/teas";
export default async function TeasPage() {
const teas = await getTeas();
return <ul>{teas.map((tea) => <li key={tea.id}>{tea.name}</li>)}</ul>;
}
A Route Handler is for callers that can't import your functions. When the shop's phone app wants the same list, a route.ts file answers it with the same function:
// app/api/teas/route.ts
import { getTeas } from "@/lib/teas";
export async function GET() {
return Response.json(await getTeas());
}
A Server Component never needs to fetch your own Route Handler. And when your own page changes data, a Server Action does the job: the form calls the function, and the function stays on the server. The short rule: if another program calls it, write a Route Handler. If your own page changes data and should show the result, write a Server Action. Fetching data in Server Components shows the first part of that rule in a recorded app.
Can Next.js replace your backend?
For short requests, yes. Reading from a database or another service, shaping the answer for one screen, and sending it back is exactly what a Next.js app does well. A server that sits between one frontend and the services behind it, built for that frontend, is called a backend for frontend, and the Next.js docs have a guide for it.
The same guide says Next.js's server features aren't a full backend replacement. Some work fits better in a backend of its own:
- Jobs that run for minutes, like a nightly import of stock from a supplier. Some hosts stop long-running Route Handlers on a timeout. A job queue and a worker can run as long as they need.
- Live connections, like a chat between staff. Where Route Handlers run as short functions that end after their answer, WebSockets won't work.
- Rules that several clients share, like the prices a website, a phone app, and partners all use. They belong in one service, so the clients never disagree.
- Teams that release on their own schedules. One app means one deploy for every change.
A quick test: if a job ends with an answer to one request within a few seconds, the Next.js app can do it. If it runs for minutes, keeps a connection open, or holds rules other clients need too, give it a backend. Many apps end up with both: services that own the data and the rules, and a Next.js app in front of them that owns the pages. Backend for frontend builds that setup step by step, and after() and background work shows the small jobs that can stay in the app.
Does a Next.js app always need a server?
No. With a static export, next build writes every page as a plain file, and any static host can put the site online. The site you're reading is a Next.js app exported this way.
The price is everything that needs a server when someone visits: reading cookies and headers, Server Actions, proxy.ts, dynamic routes the build doesn't know about, and the default image optimizer. If you need those, run next start on a Node.js server, in a Docker container, or on a platform with an adapter. Static exports and deploying Next.js compare the options.
What server skills does a Next.js developer need?
Once your code runs on a server, server mistakes become yours to avoid. These matter most:
- Every Server Action and Route Handler is public. Anyone can send it a request, with or without your form, so each one checks who's asking and what they sent. Authorization and the data access layer shows where those checks go.
- Secrets stay on the server. An environment variable without the
NEXT_PUBLIC_prefix can only be read by server code, and a module that starts withimport "server-only"can't be imported by a Client Component. Server-only code and environment variables covers both. - Only send what the page needs. Whatever a Server Component renders, or passes to a Client Component, is sent to the browser. Pick the fields first, so a private one never travels.
- Treat the database with care. One shared client, connection pooling, and queries that ask only for what the page shows. Connecting a database sets one up.
Where to go next
The Next.js course teaches both sides in order, and a full-stack Next.js project puts them together in one app with a database, sign-in, and a form that saves. To practice the server side, try the Route Handler and Server Action problems in the Next.js practice problems, like a tea review Server Action. And to say it in an interview, read when to use a Server Action or a Route Handler from the Next.js interview questions.


