Open Source · MIT License

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.

Prerequisites

What You'll Need

Node.js 18+
JavaScript runtime environment
NeonDB Account
Serverless PostgreSQL database (free tier available)
Clerk Account
Authentication & user management (free tier available)
Meta Business Account
WhatsApp Business API access via Meta Developer Portal
AWS Account
S3 bucket for media file storage
Git
Version control to clone the repository
Setup Guide

Deploy in 5 Steps

1

Clone the Repository

$ git clone https://github.com/hetref/whatsapp-chat.git
$ cd whatsapp-chat
2

Install Dependencies

$ npm install
3

Configure Environment Variables

Copy the example environment file and fill in your credentials:

$ cp .env.example .env.local
VariableDescription
DATABASE_URLNeonDB PostgreSQL connection string
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYClerk publishable key (from Clerk dashboard)
CLERK_SECRET_KEYClerk secret key (from Clerk dashboard)
WHATSAPP_ACCESS_TOKENPermanent system user token from Meta
WHATSAPP_PHONE_NUMBER_IDYour WhatsApp Business phone number ID
WHATSAPP_BUSINESS_ACCOUNT_IDYour WhatsApp Business account ID
WHATSAPP_VERIFY_TOKENCustom token for webhook verification
AWS_ACCESS_KEY_IDAWS IAM access key for S3
AWS_SECRET_ACCESS_KEYAWS IAM secret key for S3
AWS_REGIONAWS region (e.g. ap-south-1)
AWS_S3_BUCKET_NAMES3 bucket name for media storage
4

Set Up the Database

$ npx prisma migrate dev

This creates all required database tables in your NeonDB instance.

5

Start the Development Server

$ npm run dev

Open http://localhost:3000 in your browser.

Meta Cloud API

Setting Up WhatsApp Cloud API

1

Create a Meta Developer Account

Go to developers.facebook.com and create an app with the WhatsApp product enabled.

2

Generate an Access Token

Create a permanent system user token with whatsapp_business_messaging and whatsapp_business_management permissions.

3

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.

4

Add a Phone Number

Register a phone number for your WhatsApp Business account. Meta provides a free test number for development.

Deployment

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.

Architecture

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.