All notes

Do I Really Need React for This?

I use React and Next.js a lot. The more I build, the more I ask a simpler question first: does this app actually need them?

5 min readwebjavascriptreact
On this page
  1. When everything needs React
  2. A real app can be tiny
  3. What React actually buys me
  4. A rough test
  5. I still use Next.js
  6. So, do I need React?

I like React. I use React, and I use Next.js, a lot. So this isn't a "real developers use plain HTML" post.

But sometimes I look at what I'm building and ask whether it actually needs React. I never used to ask that.

When everything needs React#

A website? React. A dashboard? React. A contact page, or an admin panel with five forms and a table? React, plus a framework around it, a UI library, a state library, a data-fetching library and a form library. Suddenly 14 packages are working together to show a page called "Projects".

I'm exaggerating a little, but when you're learning modern web development it's easy to believe that's just how websites get built. You stop asking "what does this app need?" and start asking "which framework should I use?" Those are different questions.

A real app can be tiny#

Say I want a page that lists projects. The browser asks GET /projects, the server fetches the data and renders HTML:

app.get("/projects", async (req, res) => {
  const projects = await getProjects();
  res.render("projects", { projects });
});
<h1>Projects</h1>
<% projects.forEach(project => { %>
  <article>
    <h2><%= project.name %></h2>
  </article>
<% }) %>

That's not a toy. A request comes in, data is fetched, HTML is generated and the user sees their projects. There's no component tree, no hydration and no big JavaScript bundle. Sometimes that's more than enough.

A lot of tutorials start from the top: "let's build a React app". You learn React, then Next.js, then APIs, then databases, and you quietly absorb the idea that HTML is old, React is modern and Next.js is more modern. But HTML didn't stop working when React arrived. Each layer adds something, and the old ones are still underneath. The browser still wants HTML, HTTP still carries the requests, the server still does the work. If plain HTML solves the problem, that's a perfectly good answer.

What React actually buys me#

React earns its place when the interface turns into a program of its own: lots of state, things changing while the user is on the page, one change affecting several parts of the screen. A dashboard is the classic example:

Dashboard
├── Sidebar
├── Header
├── ProjectList
│   └── ProjectCard
└── ActivityFeed

Now the list is filtering, the feed is updating, a form is open, a loading state is running and one button changes three other parts of the screen. Keeping all that in sync by hand gets very annoying. React's component model and its idea of UI as a function of state help there.

So I don't ask "can I build this without React?" I probably can. The better question is: would building it without React make the problem harder?

It isn't free, either. You get a build system, more dependencies, more JavaScript in the browser, more decisions about data fetching and rendering, and with Next.js more conventions to learn. I'm happy to pay that when the app needs what I get back. For an admin panel with users, projects, settings and a save button, a server-rendered app might handle it perfectly well, and then I'm adding complexity just because it's what I started with.

A rough test#

Before reaching for React I look at the interface itself. Does a lot happen after the page loads? Are many pieces of the screen changing independently? Do several parts share state? Is there lots of interaction without full navigation? Is this going to grow?

If the page is mostly request, get data, render HTML, respond, a server and a template are fine. If it's interaction, state change, several components reacting, more requests, more state, more UI changes, then React starts making sense. There's no React police. I'm just looking at the problem.

There's also something nice about the simple version. You can follow the whole request: the route, the query, where the data came from, the HTML that came back. When you're still learning how the web works, direct is good.

I still use Next.js#

Obviously. I've built dashboards and apps with it, and this site runs on it. When I reach for it, I know why: routing, conventions, rendering options, the ecosystem, and all the wiring I don't have to do myself. That's a good trade. It's just different from saying every web app needs Next.js.

The simpler the app, the more obvious this gets. Say you're building an internal tool with a few pages, some forms, a table and a login. Build the simplest thing that works. Then the table needs filtering without navigation, then pagination, then live updates, then controls that share state. The trade-off has changed, and now React makes sense. That's how I'd rather decide: not because React is modern, or people on Twitter use it, or the job listing says so, but because the problem got bigger and this tool makes the bigger problem easier.

The web worked before React too, with HTML, PHP, Rails, Django and server-rendered templates, and people still build that way. We added tools because our apps got more complicated. If yours is complicated, use tools that make that manageable. If it isn't, don't manufacture complexity because you think you're supposed to.

So, do I need React?#

Sometimes. Maybe even most of the time, for the kind of apps I like building. But not automatically. I don't want to start with "which framework are we using?" I want to start with "what are we building?", then ask what changes on the page, what needs state, what needs the server and what will annoy me in six months. Then pick the tool, whether that's plain HTML, a server with EJS, React or Next.js.

The goal isn't to prove I can use React. It's to build the thing. And sometimes the best React app is the one you didn't need to build.