Skip to content
RailsDev.io

Ruby on Rails vs Next.js: Which Should You Choose for Your Product?

Ruby on Rails vs Next.js for SaaS: what each includes out of the box, tested, where each fits, and how to combine Rails with React using Inertia.js.

Hendra NicholasRails Full-Stack Developer & AI Engineer

Updated 9 min read

Comparison of what a new Rails 8.1 app and a new Next.js 16 app include: Next.js has React UI and routing built in; Rails has server-rendered pages, database and migrations, a sign-in generator, background jobs, email and uploads, tests and a deploy config built in, which Next.js needs libraries or services for
On this page
  1. What you’re actually comparing
  2. What a new app includes
  3. The same feature in both
  4. Background jobs and long-running work
  5. The option many teams miss: Rails with React through Inertia.js
  6. Rails vs Next.js: when to choose which
  7. Conclusion
  8. Frequently asked questions

Ruby on Rails vs Next.js is really a full-stack framework vs a React framework. Rails includes the whole back end a product needs: database and migrations, background jobs, email, file uploads, authentication, tests and deployment. Next.js includes React rendering, routing, caching and server functions, and leaves the rest of the back end to libraries and services you choose. For a SaaS heavy on business logic and data, Rails usually gets you there with fewer parts. For a product where the React interface is the core, or a team that works only in TypeScript, Next.js fits better.

To keep this concrete, I created a new app with each framework, built the same small feature in both, and noted what I had to add. I also set up the option many teams miss: Rails as the back end with React pages through Inertia.js. This article is for founders and CTOs choosing a stack, and for teams deciding how to add a React front end to a Rails app.

I tested with Rails 8.1.4 on Ruby 4.0.8, Next.js 16.4.4 (React 19.3) on Node.js 24, inertia_rails 3.23.0 and PostgreSQL 18, all as of November 2026.

What you’re actually comparing

Rails is a full-stack web framework. Its pieces (Active Record, Active Job, Action Mailer, Active Storage, Action Cable, Hotwire) are designed together and follow one set of conventions. Rails 8.1 was released in October 2025.

Next.js is a React framework. It adds server-side rendering, routing, caching and server functions to React, and runs on Node.js. Next.js 16 was announced in October 2025, with Turbopack as the default bundler and a new opt-in caching model called Cache Components. As of November 2026 the latest release is 16.4.4.

Next.js does have server-side features: Server Components can read from a database, Server Actions handle form submissions, and Route Handlers serve APIs. So “is Next.js a backend?” has a nuanced answer: it runs back-end code, but it isn’t a back-end framework in the Rails sense, because the database layer, jobs, email and auth come from elsewhere.

What a new app includes

I ran rails new and npx create-next-app@latest with their defaults and compared the results:

A new app includes Rails 8.1 Next.js 16.4
UI rendering Server-rendered HTML with Hotwire React, with server and client components
Routing Yes Yes (file-based App Router)
TypeScript No (Ruby) Yes
Tailwind CSS With --css tailwind Yes
Database layer and migrations Active Record No: add Prisma, Drizzle or similar
Sign-in generate authentication No: add Auth.js or a hosted service
Background jobs Solid Queue No: add a queue or platform service
Email, file uploads Action Mailer, Active Storage No: add libraries
Test framework Minitest, system tests No: add Vitest, Jest or Playwright
Deployment config Dockerfile and Kamal None, but Vercel deploys it with no config

The new Next.js project’s package.json had three runtime dependencies (next, react, react-dom) plus TypeScript, Tailwind and ESLint. The project also included an AGENTS.md file with instructions for AI coding agents. That’s a lean, focused start. For a SaaS, the “No” rows are the work that remains.

The same feature in both

I built the smallest real feature in each: a form that saves a project to PostgreSQL and a page that lists projects.

In Rails, one generator creates the model, migration, controller, views and tests:

bash
bin/rails generate scaffold Project name:string
bin/rails db:migrate

In Next.js, I first added a database layer. I used Drizzle, a popular TypeScript ORM, plus the PostgreSQL driver and Zod for validation:

bash
npm install drizzle-orm pg zod
npm install -D drizzle-kit @types/pg

Then a schema, a database client and a Drizzle config, and a migration with npx drizzle-kit push:

typescript
// db/schema.ts
import { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";

export const projects = pgTable("projects", {
  id: serial("id").primaryKey(),
  name: text("name").notNull(),
  createdAt: timestamp("created_at").defaultNow().notNull(),
});

A Server Action handles the form:

typescript
// app/projects/actions.ts
"use server";

import { revalidatePath } from "next/cache";
import { z } from "zod";
import { db } from "@/db";
import { projects } from "@/db/schema";

const ProjectInput = z.object({ name: z.string().trim().min(1) });

export async function createProject(formData: FormData) {
  const input = ProjectInput.safeParse({ name: formData.get("name") });
  if (!input.success) return;

  await db.insert(projects).values(input.data);
  revalidatePath("/projects");
}

And the page:

tsx
// app/projects/page.tsx
import { Suspense } from "react";
import { desc } from "drizzle-orm";
import { db } from "@/db";
import { projects } from "@/db/schema";
import { createProject } from "./actions";

async function ProjectList() {
  const rows = await db.select().from(projects)
    .orderBy(desc(projects.createdAt));

  return (
    <ul>
      {rows.map((project) => <li key={project.id}>{project.name}</li>)}
    </ul>
  );
}

export default function ProjectsPage() {
  return (
    <main>
      <form action={createProject}>
        <input name="name" placeholder="Project name" required />
        <button type="submit">Add project</button>
      </form>
      <Suspense fallback={<p>Loading projects…</p>}>
        <ProjectList />
      </Suspense>
    </main>
  );
}

It works well: the production build succeeded, the form saved a project through the Server Action even without JavaScript, and the list showed it. Server Actions are a genuinely pleasant way to handle forms.

Two things I hit that you should know about. create-next-app 16.4 turns on Cache Components (cacheComponents: true) by default. With it on:

  1. The common export const dynamic = "force-dynamic" fails the build with “Route segment config “dynamic” is not compatible with nextConfig.cacheComponents“.
  2. A page that reads from the database outside a <Suspense> boundary fails the build with “Next.js encountered uncached or runtime data during prerendering.” You choose one fix: stream it with <Suspense> (what I did above), cache it with "use cache", or allow a blocking route with export const instant = false.

These are reasonable defaults for performance, but many tutorials written before Next.js 16 don’t mention them.

The comparison isn’t “Rails is less code”, since a scaffold generates more files than I wrote by hand. It’s that in Rails the decisions are made for you, and in Next.js you choose the ORM, validation library, auth, jobs and test tools yourself. An experienced TypeScript team may prefer that freedom. A small team building a SaaS usually benefits from fewer decisions.

Background jobs and long-running work

SaaS products send emails, import files, sync with other tools and call AI APIs. That work belongs outside the web request.

In Rails, Solid Queue is built in and stores jobs in your database:

ruby
ImportJob.perform_later(upload)

In Next.js there’s no built-in job queue. On Vercel, functions run for 300 seconds by default and up to 800 seconds on paid plans, according to Vercel’s duration limits, and Vercel offers separate products (Queues, Workflows, Cron) for background work. If you host Next.js yourself, you add a queue such as BullMQ with Redis and run a worker process. Either way, it’s another piece to set up and pay for.

This is one of the most practical differences for a SaaS. My guide to Ruby on Rails AI integration shows the Rails pattern: a background job runs the slow AI call and streams the result to the browser with Turbo Streams.

The option many teams miss: Rails with React through Inertia.js

If you want React for the interface but Rails for everything else, you don’t need a separate Next.js front end and an API. Inertia.js lets Rails controllers render React (or Vue, or Svelte) pages directly, passing data as props. There’s no API layer to design and no second deployment.

I installed it in a new Rails 8.1 app with React, TypeScript, Tailwind and Vite:

bash
bundle add inertia_rails
bin/rails generate inertia:install --framework=react --typescript \
  --tailwind --vite

A controller then renders a React component with props:

ruby
class InertiaExampleController < InertiaController
  def index
    render inertia: {
      rails_version: Rails.version,
      ruby_version: RUBY_DESCRIPTION,
    }
  end
end

The page at app/frontend/pages/inertia_example/index.tsx receives rails_version as a prop. In my test, the generated example rendered the React component with the props from the Rails controller. You keep Rails’ routing, authentication, Active Record, jobs and mailers, and write the UI in React with TypeScript.

The trade-off: you don’t get Next.js features such as React Server Components or its image and caching pipeline, and Inertia pages are rendered on the client unless you set up server-side rendering. For most SaaS dashboards that’s fine.

Rails vs Next.js: when to choose which

Choose Rails if… Choose Next.js if…
Your product is mostly data, workflows and business rules Your product’s core is a rich, highly interactive React UI
You want auth, jobs, email and tests to come together Your team works only in TypeScript and React
A small team must ship a complete SaaS You need strong SEO for content-heavy, mostly public pages
You run long background work (imports, AI, email) You’ll deploy on Vercel and use its platform services

And consider combining them:

  • Rails + Inertia React for a SaaS that wants React screens without a separate API.
  • Rails API + Next.js front end when you need separate front-end and back-end teams, or a public API anyway.
  • Next.js marketing site + Rails app, so each does what it’s best at.

The broader comparison of runtimes is in Ruby on Rails vs Node.js, and the decision process for the whole stack is in how to choose a tech stack for startups. If you have a Rails app and want React screens without splitting it into two apps, that’s a common project I take on.

For the Hotwire side of that decision, see Turbo Morphing in Rails and my Hotwire vs React comparison.

Conclusion

Ruby on Rails vs Next.js isn’t a fair fight between equals, because they solve different parts of the problem. Rails gives a SaaS team the whole back end and a productive server-rendered UI in one framework. Next.js gives you an excellent React framework with server features, and leaves the database layer, auth, jobs, email and tests to libraries and services you choose. Pick Rails when your product is mostly data and workflows, pick Next.js when the React interface is the product, and remember that Rails with Inertia gives you React screens without giving up the Rails back end.

I build SaaS products on Rails, including Rails apps with React front ends through Inertia. If you’re deciding between Rails and Next.js for a new product, send me a short brief and book a discovery call.

Frequently asked questions

Is Next.js a backend framework?

Partly. Next.js runs server code (Server Components, Server Actions and Route Handlers can read and write a database), but it doesn’t include a database layer, background jobs, email, file uploads or authentication. You add those with libraries and services. Rails includes all of them.

Can I use Next.js with a Rails backend?

Yes. A common setup is a Rails API with a Next.js front end that calls it. It suits teams with separate front-end and back-end developers, but you’ll design and maintain an API and two deployments. If you only want React screens, Rails with Inertia.js is simpler.

What is Inertia.js in Rails?

Inertia.js connects a server-side framework to a React, Vue or Svelte front end without an API. Rails controllers call render inertia: with props, and the matching React component renders them. You keep Rails routing, authentication and data access, and write the interface in React.

Is Rails or Next.js better for SEO?

Both render HTML on the server, which search engines need. Next.js has strong built-in tools for static generation, image optimization and metadata, which helps content-heavy public sites. For a logged-in SaaS app, SEO mostly applies to marketing pages, which either framework, or a separate static site, can handle well.

Is Next.js faster than Rails?

It depends on what you measure. Next.js can serve static and cached pages very quickly and streams dynamic parts. Rails pages are usually fast enough for SaaS, with caching where needed. For most products, database queries and caching decisions matter more than the framework.

Should I switch from Rails to Next.js?

Usually not just for the front end. If you want React screens, add Inertia.js or React components to the Rails app instead of rewriting the back end. Consider a separate Next.js front end only if you need separate teams, a public API, or Next.js-specific features for a large public site.

Keep reading

Seven steps to build a SaaS MVP on Rails 8, each with its command: new app with Tailwind, sign-in and sign-up with the authentication generator, core workflow with a scaffold, scoping to the account, billing with pay_customer, testing with bin/ci, and deploying with bin/kamal setup
9 min read

Build Your SaaS MVP Faster with Ruby on Rails

Build a Ruby on Rails MVP faster: a tested Rails 8.1 setup with sign-up, accounts, a scoped core workflow, tests and CI, plus what to leave out of version one.