Does Ruby on Rails Work With Vercel?

Partially CompatibleLast verified: 2026-02-20

Rails can run on Vercel via serverless functions, but it's not the platform's primary use case and requires significant architectural changes.

Quick Facts

Compatibility
partial
Setup Difficulty
Complex
Official Integration
No — community maintained
Confidence
high
Minimum Versions
Ruby on Rails: 6.0

How Ruby on Rails Works With Vercel

Vercel is fundamentally designed for frontend frameworks and static sites, not monolithic backend frameworks like Rails. However, you can deploy Rails API backends to Vercel using serverless functions by converting your Rails app into a handler that Vercel can invoke. This requires restructuring your application—moving away from Rails' traditional request/response cycle and instead exporting a handler function compatible with Node.js environments. You'll need to use a gem like `rails-lambda` or write custom middleware to adapt Rails to the serverless model. The Rails frontend (if using it) can be deployed separately as a static site or Next.js app. This approach works best for lightweight API backends, but you lose many Rails conveniences like background jobs, WebSockets, and file uploads without additional services.

Best Use Cases

Deploying a Rails JSON API backend while hosting a separate Next.js frontend on Vercel
Migrating a monolithic Rails app incrementally by moving specific endpoints to serverless functions
Building lightweight microservices from Rails logic exposed as Vercel functions
Prototyping Rails APIs quickly without managing traditional server infrastructure

Rails API Handler for Vercel Serverless

bash
gem 'rails', '~> 7.0' && gem 'rack'
ruby
# api/handler.rb
require_relative '../config/environment'

Rails.application.config.eager_load = true

app = Rails.application

Handler = lambda do |event:, context:|
  # Convert Vercel event to Rack format
  env = {
    'REQUEST_METHOD' => event['httpMethod'],
    'PATH_INFO' => event['path'],
    'QUERY_STRING' => (event['queryStringParameters'] || {}).map { |k,v| "#{k}=#{v}" }.join('&'),
    'rack.input' => StringIO.new(event['body'] || ''),
    'CONTENT_TYPE' => event['headers']['content-type'] || 'application/json'
  }
  
  status, headers, body = app.call(env)
  
  { statusCode: status, headers: headers, body: body.join }
end

Known Issues & Gotchas

critical

Cold starts and execution timeouts: Serverless functions have 10-60 second timeout limits, which can be problematic for long-running Rails operations

Fix: Offload heavy operations to background jobs using external services like Sidekiq Cloud or AWS SQS; optimize database queries and avoid N+1 problems

critical

Database connection pooling breaks in serverless: Each function invocation creates new connections, exhausting database connection limits

Fix: Use a connection pooler like PgBouncer or Prisma's built-in pooling; configure Rails with a reduced database pool size

warning

Rails asset pipeline and static file serving don't work on Vercel

Fix: Use a separate frontend (Next.js, React) or serve assets from a CDN; configure Rails as API-only

warning

WebSockets and real-time features are unsupported in serverless functions

Fix: Use external services like Pusher, Socket.io, or AWS AppSync for real-time features

warning

File uploads default to ephemeral /tmp storage and don't persist between invocations

Fix: Stream uploads directly to S3 or another object storage service; avoid local file system writes

Alternatives

  • Render or Railway: Traditional cloud platforms with native Rails support, persistent processes, and zero serverless friction
  • AWS Elastic Beanstalk + Next.js on Vercel: Run full Rails backend on traditional servers while hosting React frontend on Vercel
  • Fly.io + Vercel: Deploy Rails containerized apps with websocket support on Fly.io, frontend separately on Vercel

Resources

Related Compatibility Guides

Explore more compatibility guides