Does Ruby on Rails Work With Netlify?
Rails works with Netlify, but Rails is a full-stack framework requiring a server, while Netlify is primarily a static/JAMstack platform—you'll need to host Rails elsewhere and use Netlify for the frontend only, or use Netlify Functions as a supplementary API layer.
Quick Facts
How Ruby on Rails Works With Netlify
Rails and Netlify don't have a natural fit because Rails expects a persistent server environment to handle requests, database connections, and sessions—Netlify is optimized for static files and serverless functions. The most practical approach is deploying Rails to Heroku, Render, or Railway while using Netlify for a separate frontend (React, Vue, or static content). You'd communicate via API endpoints. Alternatively, you can build a headless Rails API and deploy it traditionally elsewhere, then deploy a decoupled frontend to Netlify. Some developers use Netlify Functions (AWS Lambda) to replace specific Rails endpoints for lightweight operations, but this defeats Rails' philosophy of convention and adds complexity. For a true Rails experience with Netlify, consider a hybrid: keep Rails on a traditional host and use Netlify's edge functions for caching, redirects, and asset optimization. If you're committed to the Netlify ecosystem, Next.js, Remix, or SvelteKit provide better alignment with serverless architecture.
Best Use Cases
Rails API + Netlify Frontend Hybrid Setup
# Create a new Rails API (deploy to Heroku/Render separately)
rails new myapp --api
cd myapp
# In a separate directory, create Netlify frontend
npm create vite@latest frontend -- --template react
cd frontend
npm install# netlify.toml - Configure frontend build and API routing
[build]
command = "npm run build"
publish = "dist"
[[redirects]]
from = "/api/*"
to = "https://myapp-api.herokuapp.com/api/:splat"
status = 200
force = true
# frontend/src/api.js - Call Rails API from React
export const fetchPosts = async () => {
const response = await fetch('/api/posts');
return response.json();
};
// Deploy Rails separately:
// git push heroku main
// Deploy Netlify frontend:
// netlify deploy --prodKnown Issues & Gotchas
Rails sessions and cookies don't work with Netlify's CDN and serverless architecture without careful CORS and domain configuration
Fix: Use token-based authentication (JWT) instead of session cookies, or deploy Rails to a traditional server and Netlify for frontend only
Netlify Functions have 10-second timeout limits (on standard tier), incompatible with long-running Rails background jobs
Fix: Use Sidekiq or other background job processors on your Rails server, call them via API from Netlify Functions
Database connections from Netlify Functions are unreliable; Rails ORM expects persistent connections
Fix: Keep database access within Rails; use Netlify Functions only as a thin HTTP gateway calling Rails endpoints
Rails hot reloading and the development server workflow don't translate to Netlify's static/function model
Fix: Develop Rails locally as normal, but understand Netlify's build step only handles static assets and function uploads, not Rails runtime
Alternatives
- •Next.js (full-stack React framework) deployed on Vercel with a separate Rails/Node API backend
- •Remix (full-stack framework) deployed on Netlify with serverless functions, eliminating the need for separate Rails deployment
- •Ruby Sinatra + Netlify Functions: lighter-weight Ruby option that maps better to serverless architecture
Resources
Related Compatibility Guides
Explore more compatibility guides