Skip to main content
Vercel is the recommended platform for deploying Featul. This guide covers deployment setup, configuration, and optimization for production.

Prerequisites

Before deploying to Vercel:
1

Prepare Database

Provision a PostgreSQL database (recommended: Neon) and obtain the connection string. See Database Setup.
2

Configure Environment Variables

Prepare all required environment variables. See Environment Variables.
3

Test Build Locally

bun install
bun run build
Ensure the build completes without errors.
4

Create Vercel Account

Sign up at vercel.com if you don’t have an account.

Deployment Methods

Vercel Configuration

Featul includes a vercel.json configuration file:
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "bunVersion": "1.x"
}
This tells Vercel to:
  • Use Bun 1.x for package installation (faster than npm/pnpm)
  • Follow the OpenAPI schema for validation

Project Settings

Recommended Vercel project settings:

Build Settings

  • Framework: Next.js
  • Node.js Version: 20.x
  • Package Manager: Bun
  • Build Command: cd ../.. && bun run build --filter=app

Performance

  • Edge Middleware: Enabled (for subdomain routing)
  • Image Optimization: Enabled
  • Caching: Default Next.js caching
  • Compression: Enabled

Domain Configuration

Featul requires wildcard subdomain support for multi-tenant workspaces.

Add Custom Domain

1

Add Root Domain

In Vercel project settings:
  1. Go to Settings > Domains
  2. Add your root domain: yourdomain.com
  3. Vercel provides DNS records to configure
2

Configure DNS

Add these records to your DNS provider:
Type    Name    Value
A       @       76.76.21.21
CNAME   www     cname.vercel-dns.com
CNAME   *       cname.vercel-dns.com
The wildcard * CNAME enables workspace subdomains:
  • workspace1.yourdomain.com
  • workspace2.yourdomain.com
  • etc.
3

Add Subdomains

In Vercel, add:
  • app.yourdomain.com (main application)
  • *.yourdomain.com (wildcard for workspaces)
4

SSL Certificates

Vercel automatically provisions:
  • SSL certificate for root domain
  • Wildcard SSL for *.yourdomain.com
Wait 24-48 hours for DNS propagation and SSL issuance.

Update Environment Variables

After adding custom domain, update:
NEXT_PUBLIC_APP_URL=https://app.yourdomain.com
AUTH_COOKIE_DOMAIN=yourdomain.com
AUTH_TRUSTED_ORIGINS=https://yourdomain.com,https://app.yourdomain.com,https://*.yourdomain.com
PASSKEY_RP_ID=yourdomain.com
PASSKEY_ORIGIN=https://app.yourdomain.com

Database Migrations

Run database migrations before first deployment:
1

Set Production DATABASE_URL

export DATABASE_URL="postgresql://user:password@host/db?sslmode=require"
2

Run Migrations

bun run db:migrate
3

Verify Schema

bun run db:studio
Check that all tables are created.
Migrations must be run manually before deployment. Vercel builds don’t automatically run migrations.

Automated Migrations (Optional)

To run migrations on every deployment, add a build hook:
Automatic migrations can cause issues if migrations fail. Test thoroughly before enabling.
  1. Update package.json build script:
{
  "scripts": {
    "build": "bun run db:migrate && next build"
  }
}
  1. Ensure DATABASE_URL is available at build time:
    • Vercel: Add DATABASE_URL to environment variables
    • Check “Expose to build” option

Environment-Specific Configuration

Configure different settings for Production, Preview, and Development:
NEXT_PUBLIC_APP_URL=https://app.yourdomain.com
AUTH_COOKIE_DOMAIN=yourdomain.com
PASSKEY_RP_ID=yourdomain.com
POLAR_SERVER=production

Monitoring and Analytics

Vercel Analytics

Enable built-in analytics:
  1. Go to Analytics tab in Vercel dashboard
  2. Enable Web Analytics
  3. Add to apps/app/app/layout.tsx:
import { Analytics } from '@vercel/analytics/react'

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Analytics />
      </body>
    </html>
  )
}

Sentry Integration

Featul includes Sentry pre-configured in next.config.ts:
# Add to environment variables
SENTRY_AUTH_TOKEN=your-sentry-auth-token
Vercel automatically:
  • Uploads source maps during build
  • Tracks errors and performance
  • Links deployments to Sentry releases

Performance Monitoring

Vercel provides:
  • Speed Insights: Real user metrics (Core Web Vitals)
  • Logs: Runtime logs for API routes and functions
  • Real-time events: Live deployment and request logs
Access in Vercel dashboard under Monitoring.

Optimization Tips

1

Enable Edge Runtime for Middleware

Middleware (apps/app/src/middleware.ts) automatically runs on Vercel Edge for fast subdomain routing.
2

Use Incremental Static Regeneration

For public pages (marketing, changelog):
export const revalidate = 3600 // Revalidate every hour
3

Optimize Images

Vercel Image Optimization is pre-configured in next.config.ts:
images: {
  remotePatterns: [
    { protocol: 'https', hostname: 'lh3.googleusercontent.com' },
    // ... other allowed domains
  ],
}
4

Configure Caching Headers

For API routes:
export async function GET(request: Request) {
  return new Response(data, {
    headers: {
      'Cache-Control': 'public, s-maxage=60, stale-while-revalidate=120',
    },
  })
}

CI/CD Workflow

Vercel automatically deploys:
  • Production: Commits to main branch → app.yourdomain.com
  • Preview: Pull requests → Unique preview URL
  • Development: Other branches → Preview deployments

GitHub Integration Features

  • Deployment status checks on PRs
  • Preview deployment comments on PRs
  • Automatic rollbacks on failed deployments
  • Branch protection integration

Troubleshooting

Build Fails: “Command not found”

Error: bun: command not found
Solution: Ensure vercel.json specifies bunVersion:
{ "bunVersion": "1.x" }

Runtime Error: “DATABASE_URL not set”

Solution:
  1. Verify environment variable is set in Vercel
  2. Check it’s enabled for Production environment
  3. Redeploy after adding variable

Subdomain Not Working

Solution:
  1. Verify wildcard DNS record: CNAME * cname.vercel-dns.com
  2. Add *.yourdomain.com in Vercel domains
  3. Wait for DNS propagation (up to 48 hours)
  4. Test with: dig workspace.yourdomain.com

OAuth Redirect Error

Error: redirect_uri_mismatch
Solution: Update OAuth provider callback URLs:
  • Google: https://app.yourdomain.com/api/auth/callback/google
  • GitHub: https://app.yourdomain.com/api/auth/callback/github

Next Steps

Environment Variables

Complete environment variable reference

Database Setup

Configure and migrate your database

Cloudflare Deployment

Alternative deployment to Cloudflare

Build docs developers (and LLMs) love