Deployment options
You have several options for deploying your chatbot:Vercel (recommended)
The easiest and recommended way to deploy is using Vercel. The application is optimized for Vercel’s infrastructure and includes automatic configuration for:- AI Gateway with OIDC authentication
- Vercel Postgres database
- Vercel Blob storage
- Vercel KV (Redis)
- Environment variable management
Other platforms
You can deploy to any platform that supports Next.js 16+ applications, including:- Self-hosted Node.js servers
- Docker containers
- Other cloud providers (AWS, Google Cloud, Azure)
- Manually configure environment variables
- Set up your own PostgreSQL database
- Provide an AI Gateway API key
- Configure file storage (Vercel Blob alternative)
- Set up Redis for rate limiting
Prerequisites
Before deploying, ensure you have:PostgreSQL database
A PostgreSQL database instance for storing user data, chats, and messages. Vercel Postgres is recommended.
Build process
The application uses the following build command:- Runs database migrations automatically before building
- Builds the Next.js application with optimizations
- Generates production-ready static and server files
Database migrations run automatically during the build process, so you don’t need to run them separately in most cases.
Runtime requirements
Node.js runtime
The application requires a Node.js runtime environment. It uses:- Next.js 16.0.10
- React 19.0.1
- Server-side rendering and API routes
Environment variables
All required environment variables must be set before deployment. See the environment variables guide for a complete list.Database migrations
Database migrations are handled by Drizzle ORM and run automatically during the build process. The migration script:- Checks if
POSTGRES_URLis defined - Skips migrations gracefully if no database is configured (for preview deployments)
- Applies all pending migrations from
lib/db/migrations/ - Reports success or failure
Security considerations
Required secrets
AUTH_SECRET- Used for session encryption (generate withopenssl rand -base64 32)POSTGRES_URL- Database connection string (should not be exposed)BLOB_READ_WRITE_TOKEN- Storage access tokenREDIS_URL- Redis connection stringAI_GATEWAY_API_KEY- Required for non-Vercel deployments
Authentication
The application uses NextAuth.js for authentication with:- Credentials provider for email/password authentication
- Guest user support
- Secure password hashing with bcrypt
- Session management
Next steps
Environment variables
Complete guide to all required and optional environment variables
Database setup
Configure PostgreSQL and run migrations with Drizzle ORM
Deploy to Vercel
Step-by-step guide for deploying to Vercel