Self-Host WaChat onYour Own Infrastructure
WaChat is fully open source. Deploy it on your own servers with complete control over your data, or contribute to the project and shape its future.
What You'll Need
Deploy in 5 Steps
Clone the Repository
git clone https://github.com/hetref/whatsapp-chat.gitcd whatsapp-chatInstall Dependencies
npm installConfigure Environment Variables
Copy the example environment file and fill in your credentials:
cp .env.example .env.local| Variable | Description |
|---|---|
| DATABASE_URL | NeonDB PostgreSQL connection string |
| NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | Clerk publishable key (from Clerk dashboard) |
| CLERK_SECRET_KEY | Clerk secret key (from Clerk dashboard) |
| WHATSAPP_ACCESS_TOKEN | Permanent system user token from Meta |
| WHATSAPP_PHONE_NUMBER_ID | Your WhatsApp Business phone number ID |
| WHATSAPP_BUSINESS_ACCOUNT_ID | Your WhatsApp Business account ID |
| WHATSAPP_VERIFY_TOKEN | Custom token for webhook verification |
| AWS_ACCESS_KEY_ID | AWS IAM access key for S3 |
| AWS_SECRET_ACCESS_KEY | AWS IAM secret key for S3 |
| AWS_REGION | AWS region (e.g. ap-south-1) |
| AWS_S3_BUCKET_NAME | S3 bucket name for media storage |
Set Up the Database
npx prisma migrate devThis creates all required database tables in your NeonDB instance.
Start the Development Server
npm run devOpen http://localhost:3000 in your browser.
Setting Up WhatsApp Cloud API
Create a Meta Developer Account
Go to developers.facebook.com and create an app with the WhatsApp product enabled.
Generate an Access Token
Create a permanent system user token with whatsapp_business_messaging and whatsapp_business_management permissions.
Configure Webhooks
Point your webhook URL to your deployment (e.g., https://yourdomain.com/api/webhook/your-token) to receive incoming messages and status updates.
Add a Phone Number
Register a phone number for your WhatsApp Business account. Meta provides a free test number for development.
Deploy Anywhere
Vercel
One-click deploy with automatic SSL and edge functions.
Docker
Containerized deployment for any cloud provider.
VPS
Traditional server setup with PM2 or systemd.
System Architecture
Frontend
- Next.js App Router with Server & Client Components
- Shadcn/ui component library with Tailwind CSS
- Optimistic UI updates for instant feedback
- Dark mode support with next-themes
- Responsive design for all device sizes
Backend
- Next.js API Routes for server-side logic
- Prisma ORM with NeonDB (PostgreSQL)
- AWS S3 for media storage with pre-signed URLs
- Clerk Auth for secure authentication
- Multi-tenant architecture with data isolation
Contribute to WaChat
WaChat is built by the community, for the community. Whether it's a bug fix, new feature, or documentation improvement — every contribution matters.