Change your colour scheme

Why I don’t write React anymore


Earlier this year I made the decision to stop working in React. I’d just come out of a project using a modern JS tech stack that used Next.js, and I couldn’t get over how complex the whole thing had become, and how little I enjoyed the work.

It felt like every new feature and change had a huge overhead. To create a modal dialog, creating something extremely common, like a dialog, became like reinventing the wheel each time: create the dialog component, oh, now we need a component for the content, and now we also need components for the controls (which are different each time), and now we need to handle the component lifecycle with hooks. Suddenly, without realising, a dialog takes 4 different files and a whole plate of spaghetti code to get functional.

Every component feels like a chore. In short, it felt that like for every feature I was trying to force the browser to do what I wanted it to. All of it to produce the same features that already exist in the browser natively, but I needed to abstract away so that I could do things like manage the user’s state. Instead of progressively enhancing the user’s experience to provide far-reaching compatibility, we’re starting at the most-complex state and attempting to work backwards.

What do I use instead

For most projects, I’ve found you don’t need a slow, JS-laden server-side generated web app with hydration and all of the overheads that come with it. If all I’m making is a static or infrequently-updated website, I’ll use something like Eleventy (which this website is built with). Otherwise, I’ll generally opt for a “classic” multi-page application. A backend server that handles the business logic, and uses that to provide data to the frontend.

This means that I can build fast client-side experiences, without sending a huge javascript bundle. If I need some client-side interactivity, Web Components are standardised and at least partially supported across all major browsers. Likewise, if I need reusable components, templating languages like Nunjucks can provide that without adding too much complexity.

About the author

My face

I'm Lewis Dale, a software engineer and web developer based in the UK. I write about writing software, silly projects, and cycling. A lot of cycling. Too much, maybe.