Skip to content
Tech News
← Back to articles

We moved Railway's frontend off Next.js. Builds went from 10+ mins to under 2

read original get Next.js Build Optimization Guide → more articles
Why This Matters

Railway's switch from Next.js to Vite + TanStack Router significantly reduced frontend build times from over 10 minutes to under 2, enabling faster iteration and more efficient development. This transition aligns with their client-driven, real-time, and highly interactive application needs, demonstrating the importance of choosing a framework that matches specific product requirements. The move highlights the value of flexible, fast, and type-safe routing solutions tailored for modern web applications.

Key Takeaways

Railway's entire production frontend no longer runs on Next.js. The dashboard, the canvas, railway.com, all of it now runs on Vite + TanStack Router, and we shipped the migration in two PRs with zero downtime.

Next.js got railway.com from zero to a production app serving millions of users monthly. It's an excellent framework, but it stopped being the right one for our product.

Frontend builds had crept past 10 minutes. Six of those minutes were Next.js alone, half of it stuck on "finalizing page optimization." For a team that ships multiple times a day, that kind of build time isn't a minor annoyance. It's like a very expensive tax on every single iteration.

Railway’s app is overwhelmingly client-side. The dashboard is a rich, stateful interface. The canvas is real-time. Websockets are everywhere. The server-first primitives in Next.js weren't something we used, and we'd ended up building our own abstractions on top of the Pages Router just to support layouts and routing concerns that the framework didn't handle the way we needed.

We were still on the Pages Router, which made shared layouts hacky. Every layout pattern was a bolted-on workaround rather than a first-class framework primitive. The App Router would have solved some of these problems, but it leans heavily into server-first patterns, and our product is intentionally client-driven. Adopting it would have meant rebuilding around a paradigm we don't need.

We wanted a stack that matches how we actually build: explicit, client-first, and fast to iterate on. It also helps that we genuinely enjoy working with it.

For the Product team, we wanted a few niceties that help us avoid thinking about how we needed to implement our front-end and found the following to really convince us.

Type-safe routing out of the box. Route params and search params are inferred, autocomplete works across the entire route tree, and the routes themselves are generated from the file system.

First-class layouts. Pathless layout routes replaced all of our previous hacks with something composable and predictable.

A dev loop fast enough that you stop thinking about it. Instant HMR, near-zero startup time. The feedback cycle between changing code and seeing the result effectively disappears.

... continue reading