img
gradient

Why I Choose Next.js Over React + Express for Most Cases

Written by Upeksha Indeewara

Recently, a lot of people have asked me why I use the Next.js framework rather than React with Express or other backend frameworks.

Quick Question: Have you ever wondered why your React app isn’t showing any results on Google or other search engines? Even if you try using Google Search Console, it still fails, right? Why doesn’t it load social previews like other websites? And with just a small oversight, your React app can become vulnerable to security issues.

The most suitable answer is: Next.js solves these problems. Let me explain.

First, let’s identify the key differences between a library and a framework.

  • React is a library, meaning you control the flow. You decide how to use it and what other tools to bring in, like routing or backend logic. It focuses only on the UI.

  • Next.js is a framework. It controls more of the structure, offering built-in routing, API handling, SSR, cron jobs, and more. It calls your code, not the other way around. If you’ve used Angular, it’s another example of a framework—it dictates how your app is structured from the start.

Yes! It’s Still React (Just Smarter 😎)

One common misconception is that switching to Next.js means giving up React. But that’s not true at all. Next.js is still powered by React under the hood. You write components the same way, use hooks like useState, useEffect, and build your UI just like you would in any React project.

The difference is:

  • By default, components run on the server, which improves performance and reduces client-side JavaScript.

  • If you need interactivity, you can mark components as 'use client' and they’ll behave just like traditional React components in the browser.

This hybrid model gives you full control, Use server components for performance and SEO, and client components where interactivity is essential. In short: Next.js doesn’t replace React. Just supercharges it.


Common Issues with React Apps and How Next.js Solves Them

While React (with Express or other backends) gives you flexibility, it also leaves you to solve many complex issues on your own. Here are some real challenges I’ve faced and how Next.js makes them easier.

1. SEO Limitations in React (Client-Side Rendering)

React apps are typically rendered on the client side, meaning the browser loads a blank HTML page first, then fetches and renders the UI using JavaScript. This can be problematic for SEO, as search engine bots may not wait for the JavaScript to load, causing your pages to be invisible to crawlers.

Next.js Fixes This:
Next.js supports Server-Side Rendering (SSR) and Static Site Generation (SSG) out of the box. It generates fully rendered HTML pages that bots can crawl instantly, improving visibility and ranking.

2. Poor Bot Crawling for Social Previews

When sharing a React site on social platforms like Twitter or LinkedIn, you often see empty or incorrect previews because those platforms rely on meta tags, which client-side apps don’t deliver immediately.

Next.js Fixes This:
With SSR, Next.js ensures meta tags are already present in the HTML when crawlers hit your page—so previews and metadata work as expected.

3. Slower Loading and Rendering Times

In traditional React apps, especially when combined with Express APIs, the initial load can be sluggish. You load the JS bundle, then fetch data, and then render. This leads to longer Time to First Byte (TTFB) and reduced performance on slower devices.

Next.js Fixes This:
Next.js allows you to fetch data server-side and deliver a fully rendered page immediately, reducing load times. With options like ISR (Incremental Static Regeneration), you can even pre-render dynamic content at build or runtime without overloading your server.

4. Image Optimization is Manual in React

Handling media in React apps is often manual. You have to compress images, manage responsive sizes, and optimize formats yourself. This is error-prone and inconsistent across devices.

Next.js Fixes This:
Next.js includes a powerful <Image /> component that automatically:

  • Optimizes images on-demand

  • Resizes them based on screen size

  • Uses modern formats (like WebP)

  • Lazy-loads by default

This reduces payload size and improves Core Web Vitals.

5. Folder and Route Management is Verbose

In React + Express setups, routing is fully manual. You define routes in React using react-router-dom, and again in Express for APIs. This creates duplicate logic and potential for mismatches.

Next.js Fixes This:
With file-based routing, you define routes simply by creating files in the pages/ or app/ directory. For APIs, just drop a file inside pages/api/, and it’s instantly available as an endpoint.

Even better, with the App Router and Server Actions, you can now write server logic directly inside components—securely calling server-side functions without managing separate endpoints or syncing state.

6. Cleaner API Handling with Server Actions

In React + Express, your API and UI layers are often split, requiring REST or GraphQL setup, HTTP calls, and CORS handling even for internal logic.

Next.js Fixes This:
With Server Actions and Server Components (in the App Router), you can:

  • Write async server functions directly inside your UI code

  • Avoid manual API calls for internal logic

  • Securely access backend resources (e.g. databases) without exposing routes

This leads to simpler, faster, and more secure fullstack code—ideal for rapid prototyping and production apps.


Handling Auth, Sessions, and the Boring Stuff

Building fullstack apps means you also need to handle things like authentication, sessions, middleware, and data fetching. In React + Express, these are possible but often scattered and custom.

Here’s how Next.js makes it smoother.

Authentication Made Easier

In React + Express, managing auth means setting up sessions manually with express-session, configuring CORS, writing login routes, and securing APIs—all from scratch.

Next.js Fixes This:

  • With Auth.js (formerly NextAuth.js), you get a powerful authentication layer that works seamlessly with Next.js

  • Built-in support for OAuth providers (Google, GitHub, Discord, etc.)

  • Easy session management with secure, HTTP-only cookies

  • First-class integration with App Router, middleware, and server actions

You can handle login, registration, and protected routes with far less boilerplate—and your session is already available when the page loads.

Session Management Built-In

Next.js apps, especially with middleware and server actions, allow you to:

  • Read and write cookies on the server securely

  • Use middleware to check sessions before rendering pages

  • Prevent flickering between unauthenticated/authenticated states

You don’t need to wait for the client to figure it out—pages render with session context already resolved.

Edge and Middleware Support

Next.js can run middleware at the edge, giving you near-instant access control, logging, and geolocation checks before the page even renders. Try doing that easily with Express.

Database and API Integration

Next.js works beautifully with ORMs like Prisma, Drizzle, or tools like tRPC, letting you:

  • Access your database securely in server components or server actions

  • Avoid writing HTTP API calls for internal data

  • Share types end-to-end if using TypeScript


Less Boilerplate, More Focus

Ultimately, you write less glue code—no manual CORS setup, no separate API servers, no duplication of validation logic. You can build and ship features faster without reinventing the wheel.


Final Thoughts

React is a powerful tool for building UI, but it often requires heavy lifting when building fullstack apps. Next.js takes that same power and wraps it in a smart, scalable framework that handles routing, server logic, SEO, performance, and deployment—all while letting you stay in the React ecosystem. So the next time you're choosing between React + Express and Next.js, ask yourself:
Do I want to build everything from scratch or focus on shipping features?


For me, the choice is clear: Next.js wins in most real-world scenarios.