Deployment

Options for deploying your NestSaaS application

Deploying NestSaaS

This section covers the various options for deploying your NestSaaS application to production environments. NestSaaS is built on Next.js and can be deployed to various hosting platforms.

Deployment Options

NestSaaS can be deployed to:

Pre-Deployment Checklist

Before deploying your NestSaaS application, ensure you have:

  1. Configured your environment variables
  2. Set up your database
  3. Configured authentication providers
  4. Set up storage for media files
  5. Tested your application locally

Vercel Deployment

Vercel is the recommended platform for deploying NestSaaS applications, offering seamless integration with Next.js.

Steps for Vercel Deployment

  1. Create a Vercel account if you don't have one
  2. Connect your GitHub, GitLab, or Bitbucket repository
  3. Configure your environment variables in the Vercel dashboard
  4. Deploy your application
# Install Vercel CLI
pnpm add -g vercel
 
# Login to Vercel
vercel login
 
# Deploy
vercel

Detailed Vercel Deployment Guide

Netlify Deployment

Netlify is another excellent option for hosting NestSaaS applications.

Steps for Netlify Deployment

  1. Create a Netlify account if you don't have one
  2. Connect your GitHub, GitLab, or Bitbucket repository
  3. Configure your build settings:
    • Build command: pnpm build
    • Publish directory: .next
  4. Configure your environment variables in the Netlify dashboard
  5. Deploy your application

Detailed Netlify Deployment Guide

Self-Hosted Deployment

For complete control over your hosting environment, you can self-host NestSaaS.

Requirements for Self-Hosting

  • Node.js server (v18.x or later)
  • Database server (PostgreSQL recommended)
  • Storage solution for media files
  • HTTPS certificate

Deployment Options

  • Docker containers
  • Traditional VPS or dedicated server
  • Kubernetes cluster

Detailed Self-Hosted Deployment Guide

Database Considerations

PostgreSQL

For production deployments, we recommend:

  • Using a managed PostgreSQL service (AWS RDS, DigitalOcean Managed Databases, etc.)
  • Setting up proper backups
  • Configuring connection pooling

Connection Pooling

For optimal database performance, configure connection pooling:

// prisma/client.ts
import { PrismaClient } from '@prisma/client'
 
const globalForPrisma = global as unknown as { prisma: PrismaClient }
 
export const prisma =
  globalForPrisma.prisma ||
  new PrismaClient({
    log: ['query'],
    connectionLimit: 5,
  })
 
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

Media Storage

For production deployments, we recommend using a cloud storage solution:

  • Amazon S3
  • Cloudflare R2
  • Google Cloud Storage

Learn more about configuring storage

Performance Optimization

Caching

Implement caching strategies:

  • Static page generation where possible
  • CDN caching
  • API response caching

Content Delivery Network (CDN)

Use a CDN to serve static assets and cached pages:

  • Vercel Edge Network (built-in with Vercel deployments)
  • Cloudflare
  • Fastly
  • Amazon CloudFront

Monitoring and Logging

Set up monitoring and logging for your production deployment:

  • Application logs
  • Error tracking (Sentry, LogRocket)
  • Performance monitoring
  • Uptime monitoring

CI/CD Pipeline

Implement a CI/CD pipeline for automated testing and deployment:

  • GitHub Actions
  • GitLab CI/CD
  • Jenkins
  • CircleCI

Next Steps