Repository navigation
Getting Started
- React 18 or 19 (peer dependency).
- A WhatsApp-enabled phone number with its country code.
- An ESM-aware bundler (Vite, Next.js, Remix, webpack 5, etc.). The package ships ESM only, with TypeScript types.
npm install whatsapp-chat-widget-reactRender it once, near the root of your app:
import { WhatsAppChat } from 'whatsapp-chat-widget-react';
export default function App() {
return (
<>
{/* ...your app... */}
<WhatsAppChat phoneNumber="+12025550123" title="How can we help?" />
</>
);
}That is all that is needed. The widget injects its own styles the first time it renders, so there is no CSS file to import.
phoneNumber must be in international format:
- 7 to 15 digits, with an optional leading
+. - The first digit cannot be
0. - No spaces, dashes, brackets or local dialing prefixes.
| Input | Result |
|---|---|
+2348012345678 |
Valid |
2348012345678 |
Valid |
08012345678 |
Invalid (local format) |
+234 801 234 5678 |
Invalid (spaces) |
If the number is invalid, the form shows a notice and the submit button is disabled, so you will see the problem straight away in development.
- A green launcher in the bottom-right corner: "Chat on WhatsApp".
- Clicking it opens a panel with Name, Subject and Message fields.
- "Open in WhatsApp" opens a draft in WhatsApp (a new tab) with the text already filled in.
The draft looks like this:
Name: Ada
Subject: Order question
Hi, where is my order?
A few quick changes. Everything is documented in the Props Reference.
// Round icon only, bottom-left
<WhatsAppChat phoneNumber="+12025550123" variant="icon" position="bottom-left" />
// Bright WhatsApp green, larger
<WhatsAppChat phoneNumber="+12025550123" theme="brand" size="lg" />
// Just a message box, no name or subject
<WhatsAppChat phoneNumber="+12025550123" fields={{ name: false, subject: false }} />Use the Script-Tag Build: one <script> tag, no build step. It works on WordPress, Webflow, Shopify, Squarespace and plain HTML.
- Let visitors pick a person or department: Agents and Business Hours.
- Know where leads came from: Page Context and Attribution.
- Chat inside the widget: Live Chat. Add AI: Bring Your Own AI. Save every lead: Lead Webhooks.
Release notes are in the CHANGELOG. Versions before 1.0 may add options in minor releases; existing props keep working, and deprecated ones (such as iconOnly) are called out there.
Upgrading to 0.8 changes nothing unless you use the new props: live chat, AI, lead webhooks and the hook are all opt-in, and the form looks and behaves as before.
If you imported whatsapp-chat-widget-react/styles.css in an older version, you can remove that import. Keeping it is harmless.