Next.js is a React framework for building websites and web applications. It adds what React alone leaves to you: routing, server rendering, static generation, data fetching, image optimisation and a build system. This guide explains what Next.js is, its core features, how it fits with the stacks you may already use (MERN, headless CMS, Jamstack and PHP back ends), and where to run it on Domain India.
Next.js turns React into a full framework. New projects use the App Router, where components render on the server by default, pages can be static, dynamic or regenerated on a schedule, and route handlers and Server Actions replace much of a separate API. It works as the front end of almost any stack: in place of plain React in MERN, in front of a headless CMS, as a static Jamstack site, or on top of a PHP or Python API. On Domain India, upload a static export to shared hosting, or run a server-rendered app on the App Platform or a VPS.
1. What Next.js adds to React
React draws the user interface. A real website also needs URLs, SEO-friendly HTML, data loading, images and a production build. Next.js provides these with sensible defaults:
app/ become URLs. app/blog/[slug]/page.tsx serves every blog post.app/api/.../route.ts files answer API requests inside the same project.next/image resizes and lazy-loads images; next/font self-hosts fonts.Create a project with:
npx create-next-app@latest my-app
cd my-app
npm run dev # development server on http://localhost:3000Check the Next.js documentation for the Node.js version the current release needs; use a Node.js LTS release.
2. Rendering: static, dynamic and in between
| Mode | When the HTML is made | Good for |
|---|---|---|
| Static | At build time | Marketing pages, blogs, documentation |
| Dynamic (server-side) | On every request | Dashboards, personalised pages, search results |
| Incremental regeneration | At build, then refreshed after a set time or on demand | Product catalogues, news that changes often |
| Streaming | Sent in parts as data arrives | Pages with one slow section |
In the App Router, a page is static unless it reads something that differs per request, such as cookies or uncached data. You can mix modes: a static product page with a dynamic stock count is normal. Newer releases add finer caching controls, so read the caching section of the documentation for the version you install.
3. Server Components and Server Actions
Server Components run only on the server. They can query a database or call an API directly, and their code never reaches the browser, which keeps pages light. Add "use client" at the top of a file only when a component needs state, effects or browser events.
Server Actions are server functions you call from a form or button, which removes much of the fetch-and-API boilerplate for simple changes:
// app/contact/page.tsx
async function send(formData: FormData) {
"use server";
const email = String(formData.get("email") ?? "");
// validate, then save or send
}
export default function Contact() {
return (
<form action={send}>
<input name="email" type="email" required />
<button type="submit">Send</button>
</form>
);
}Treat every Server Action like a public API endpoint: validate the input and check that the user is allowed to act. For the App Router in depth, read Next.js App Router modern patterns.
4. Next.js across stacks
| Stack | Where Next.js fits | What it replaces or adds |
|---|---|---|
| MERN | The React front end, plus server rendering | Plain React; some Express routes move into route handlers |
| MEAN | An alternative front end to Angular | Angular, if the team prefers React |
| Headless CMS | The website in front of WordPress, Strapi or a hosted CMS | The CMS theme layer |
| Jamstack | A static site built at deploy time | A static site generator |
| PHP or Python back end | The front end calling a Laravel, Django or FastAPI API | Server-rendered PHP templates |
| Full stack | Pages, API and database access in one project | A separate back-end service |
- MERN and MEAN: keep Express or NestJS for a large API, background jobs or WebSockets, and let Next.js serve the pages. For small apps, route handlers and an ORM such as Prisma can replace the separate server. See Prisma with Next.js.
- Headless CMS: editors keep the CMS; Next.js fetches content through its API and builds fast pages. Regeneration updates a page when content changes without a full rebuild. See Strapi on a VPS.
- Jamstack: set
output: 'export'and the build produces plain HTML, CSS and JavaScript that any web server can host. - LAMP: Next.js does not run inside Apache and PHP. Either export it as static files served by Apache, or run it as a Node.js app beside your PHP API.
5. Strengths and trade-offs
- SEO-friendly HTML without a separate server-rendering setup
- One project for pages, API routes and data access
- Mixing static and dynamic pages in the same site
- A large React ecosystem and active development
- A learning curve: server and client components, caching rules
- Fast-moving releases; read the upgrade guide before a major version
- Server features need a Node.js host, not plain shared hosting
- Long-running jobs and WebSockets belong in a separate service
6. Best practices
- Keep secrets on the server. Only variables prefixed
NEXT_PUBLIC_are sent to the browser; never put API keys in them. - Default to Server Components. Add client components only where interaction is needed.
- Use
next/imageandnext/fontto avoid slow images and layout shifts. - Validate everything in route handlers and Server Actions, and check authorisation on the server, not only in the UI.
- Cache deliberately. Decide for each page whether it is static, dynamic or regenerated.
- Keep Next.js updated. Security fixes arrive in patch releases.
7. Running Next.js on Domain India
Which product fits depends on whether your site needs a Node.js server at run time. The full comparison, including Vercel and Cloudflare, is in Next.js hosting: shared vs VPS.
- Shared hosting (static export): build with
output: 'export'on your computer and upload theout/folder topublic_html. You lose server rendering, route handlers, Server Actions, proxy/middleware and built-in image optimisation. - App Platform: Node.js apps are detected and built automatically. Your app must listen on the
PORTenvironment variable and bind to0.0.0.0;next startreadsPORT. Pushing to GitHub doesn't deploy by itself: click Deploy Now or use a deploy token in CI. The App Platform does not support WebSockets. See getting started with the App Platform. - VPS: a self-managed server where you run
next startbehind a reverse proxy, with your own database and background workers.
The cards show live Domain India prices, excluding 18% GST.
- 512 MB RAM per app
- 1 vCPU
- 5 GB NVMe SSD
- PostgreSQL Database
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
Frequently asked questions
What is Next.js used for?
Next.js is a React framework for websites and web apps. It adds file-based routing, server rendering, static generation, API route handlers and image optimisation, so it suits marketing sites, blogs, shops, dashboards and SaaS front ends.
Is Next.js a front-end or back-end framework?
Both. It renders React pages on the server and in the browser, and its route handlers and Server Actions can run back-end logic. Large apps often still keep a separate API for heavy or long-running work.
Should I use the App Router or the Pages Router?
Use the App Router for new projects; it is the default in create-next-app and supports Server Components and Server Actions. The Pages Router still works for existing apps.
Can I use Next.js with a PHP or WordPress back end?
Yes. Next.js can fetch data from a Laravel or other PHP API, or from WordPress used as a headless CMS, and render the pages itself.
Can I host Next.js on Domain India shared hosting?
Yes, as a static export: build with output set to export and upload the out folder to public_html. Server rendering, API routes and Server Actions need the App Platform or a VPS.
Does the Domain India App Platform run Next.js?
Yes. The App Platform detects and builds Node.js apps automatically. The app must listen on the PORT environment variable and bind to 0.0.0.0. The App Platform does not support WebSockets.
Ready to deploy your Next.js app? Read Next.js hosting: shared vs VPS, compare the App Platform and VPS plans, or open a ticket if you need help choosing.
Node.js apps are detected and built automatically, with free SSL and your own domain.
See the App Platform