Does NestJS Work With Vercel?

Partially CompatibleLast verified: 2026-02-20

NestJS can run on Vercel, but only as a serverless function—not as a traditional always-on server, which limits some NestJS features.

Quick Facts

Compatibility
partial
Setup Difficulty
Moderate
Official Integration
No — community maintained
Confidence
high
Minimum Versions
NestJS: 9.0.0

How NestJS Works With Vercel

NestJS applications can be deployed to Vercel by converting them into serverless functions using the `@nestjs/platform-express` adapter and wrapping them for Vercel's function runtime. However, this fundamentally changes the application model: Vercel is optimized for stateless, request-response workloads with strict cold-start and execution time limits (10-60 seconds depending on plan), while NestJS is designed for long-running server processes. This means features like persistent WebSocket connections, background jobs, and in-memory caching become problematic. Most developers use Vercel for NestJS APIs that handle HTTP requests only, treating it as a lightweight REST endpoint handler rather than a full enterprise server. For production systems requiring WebSockets, real-time features, or complex state management, deploying NestJS to traditional platforms like Railway, Render, or DigitalOcean App Platform is more appropriate.

Best Use Cases

Lightweight REST APIs and microservices that scale to zero when unused
Backend-for-frontend (BFF) layer for static site generation or SSR with Vercel frontend
Simple CRUD operations with quick execution times and minimal dependencies
Serverless webhooks and event handlers that don't require persistent connections

Quick Setup

bash
npm install @nestjs/core @nestjs/common @nestjs/platform-express
typescript
// src/main.ts - Vercel serverless handler
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter } from '@nestjs/platform-express';
import { AppModule } from './app.module';
import express from 'express';

const expressApp = express();

export default async (req: any, res: any) => {
  const app = await NestFactory.create(
    AppModule,
    new ExpressAdapter(expressApp),
    { logger: false },
  );
  await app.init();
  expressApp(req, res);
};

// vercel.json
{
  "functions": {
    "api/index.ts": {
      "memory": 1024,
      "maxDuration": 30
    }
  }
}

Known Issues & Gotchas

critical

Cold starts and 10-60 second execution limits impact real-time features

Fix: Avoid WebSockets, streaming, and long-running operations. Use serverless-friendly patterns like request queuing to external services.

warning

In-memory state and caching are lost between invocations

Fix: Use external databases (PostgreSQL, Redis) instead of in-memory stores. Enable function caching if using Vercel Pro.

warning

TypeORM and heavy ORMs cause large cold start times

Fix: Use lightweight query builders like Prisma with connection pooling, or direct SQL queries.

info

Environment variables and secrets must be managed through Vercel dashboard

Fix: Use Vercel's environment variable UI or link your Git repository for automatic secret injection.

Alternatives

  • Express.js + Vercel (lighter weight, better cold start performance)
  • NestJS + Railway or Render (traditional containerized deployment with full feature support)
  • NestJS + AWS Lambda with Serverless Framework (more control over serverless environment)

Resources

Related Compatibility Guides

Explore more compatibility guides