So as to not be disingenuous, I suspect you're making a false dichotomy that rails = backend and nextjs = frontend and so they solve different problems?
But that said, I do sometimes choose Next.js because to me the biggest problem it solves is performance by allowing doing the rendering where it makes the most sense, even within the same page. Next.js allows you to seamlessly do rendering at different points depending on requirements. For example the static portions can be rendered once at build time (SSG) and served statically. If you don't have any dynamic stuff you can just serve your whole site with nginx and not even have node in the deployed stack! You can also SSR on each request, which allows you to do compute intensive things very quickly, and allows rendering differently based on server-side information (like DB queries, etc). You can also use standard client-side rendering for stuff that fits better there. That's especially useful for menus and reactive components.
It makes sense why nextjs kills my soul every time I touch it. For side-projects it's just me, for startups it's a few people where the entire premise of the company may change monthly, not to mention the API and product assumptions.
Perhaps it's just the millennial in me. Intentional frontend/backend bounded expertise is rather silly in a fledgling company.
Adding a separate JS frontend is a good way to double your costs and dev time. There's few situations that demand such heavy JS but people follow trends like sheep. And I say that as a frontend engineer who wrote JS/TS for a decade.