Hacker News new | ask | show | jobs
by gl-prod 721 days ago
Let's say a medium Nextjs v10 side project. The goal is to update it as quickly as possible. It's just me.
1 comments

What is it for? Why do you want to upgrade? What are the constraints? Do you need to maintain 100% feafure parity?

10 to modern Next is a pretty big leap, especially if you're also going to move to the app router. The code mods might help a bit but not completely. Do you have older React code (class components etc.) or libs (old redux) and huge state trees?

If so it might be easier to rewrite the whole thing.

I've had to do a few rewrites like that and would typically do an exploratory investigation of each approach for a day or two, trying to better estimate the difficulty of each by partially starting a migration and partially starting a rewrite. Along the way I'd come up with a list of must haves vs nice to haves vs nice to get rid of, and use that to make a final decision.

But realistically, IMO a rewrite is inevitably cleaner (maybe with some functions manually ported over) and more maintainable over the long term.

Partial migrations for something like this means a lot of technical debt in the future. Next and React move too fast to keep up with piecemeal migrations like this cleanly. It's a very unstable ecosystem.

I'd probably end up extracting out the parts into modular components wherever possible, separating the business logic from the Next stuff (routing and caching and building) and the state stuff (meaning keeping components as pure as possible so state can be easily provided via whatever framework is popular that year)