Prerequisites
Before you begin, make sure you have:- Node.js 20+ (download)
- Bun (install with
curl -fsSL https://bun.sh/install | bash) - A GitHub account (for cloning and OAuth)
Understanding bun chatjs:init
The bun chatjs:init command generates a chat.config.ts file with sensible defaults. This file controls all feature toggles, branding, and app settings.
What the default config includes
What the default config includes
The default configuration gives you a minimal, working setup:
This keeps your initial setup simple—you only need
| Setting | Default | Notes |
|---|---|---|
| Authentication | GitHub only | Google and Vercel OAuth disabled |
| Integrations | All disabled | No sandbox, web search, MCP, image generation, or attachments |
| Anonymous users | 10 credits | Limited access, no tools |
| Models | Curated list | GPT-5 Nano/Mini, Gemini 2.5 Flash Lite, Claude Sonnet 4.5 |
DATABASE_URL, AUTH_SECRET, AI_GATEWAY_API_KEY, and GitHub OAuth credentials to get started.Enable features incrementally by editing chat.config.ts and adding the required environment variables. See Configuration for details.- Vercel (Recommended)
- Manual Setup
The fastest path to production. Vercel handles database, blob storage, and AI Gateway automatically.
This creates a new repo in your GitHub account and deploys it to Vercel. During setup, Vercel provisions:
Then add credentials for at least one OAuth provider:
Open http://localhost:3000. You should see the ChatJS interface with a model selector and chat input.
1. Deploy to Vercel
- PostgreSQL database
- Blob storage
- AI Gateway access (120+ models)
2. Configure Authentication
In the Vercel dashboard, go to Settings → Environment Variables and add:| Variable | Description |
|---|---|
AUTH_SECRET | Generate one |
GitHub (Recommended)
GitHub (Recommended)
- Go to GitHub Developer Settings
- Click New OAuth App
- Set Homepage URL to your Vercel deployment URL
- Set Authorization callback URL to
https://YOUR_APP.vercel.app/api/auth/callback/github - Copy the Client ID →
AUTH_GITHUB_ID - Generate a Client Secret →
AUTH_GITHUB_SECRET
Google
- Go to Google Cloud Console
- Create a new OAuth 2.0 Client ID (Web application)
- Add Authorized redirect URI:
https://YOUR_APP.vercel.app/api/auth/callback/google - Copy Client ID →
AUTH_GOOGLE_ID - Copy Client Secret →
AUTH_GOOGLE_SECRET
Vercel
Vercel
- Go to Vercel Integration Console
- Create a new integration with Sign In with Vercel
- Copy Client ID →
VERCEL_APP_CLIENT_ID - Copy Client Secret →
VERCEL_APP_CLIENT_SECRET
3. Set Up Local Development
Clone your new repo and pull environment variables from Vercel:4. Run Database Migrations
5. Start the Dev Server
Troubleshooting
Missing environment variables error
Missing environment variables error
ChatJS validates env vars at build time. Check
.env.local has all required variables and restart the dev server.Database connection failed
Database connection failed
Verify
DATABASE_URL is correct and the database is running. For local PostgreSQL, check the service is started.OAuth redirect error
OAuth redirect error
Make sure the callback URL in your OAuth app matches exactly. For local dev, use
http://localhost:3000/api/auth/callback/{provider}.Optional Features
Optional Features
These environment variables enable additional capabilities:
| Variable | Feature | Setup Guide |
|---|---|---|
REDIS_URL | Resumable streams | Vercel KV |
TAVILY_API_KEY | Web search | Tavily |
FIRECRAWL_API_KEY | Web search | Firecrawl |
LANGFUSE_PUBLIC_KEY | LLM observability | Langfuse |
LANGFUSE_SECRET_KEY | LLM observability | Langfuse |
MCP_ENCRYPTION_KEY | MCP connectors | openssl rand -base64 32 (must be exactly 44 chars) |
CRON_SECRET | Cleanup cron job | Generate |