Most WhatsApp widgets on npm are just a floating icon that drops visitors into an empty chat box. Businesses end up with vague "Hi" messages, zero context on what page the visitor was viewing, and no record of leads who clicked the button but closed WhatsApp before hitting send.
I built whatsapp-chat-widget-react (now at v0.8.0 and already crossing 320+ weekly downloads in its first few days!) to solve this with a form-first, zero-dependency, privacy-aware architecture—plus a standalone <script> tag build for sites that don't use React.
👉 Try the Interactive Live Playground | ⭐ GitHub Repository | 📦 npm Package
What Makes whatsapp-chat-widget-react Different?
Form-First Pre-Qualification (Zero Backend Required by Default)
Visitors fill out a clean, accessible contact form (Name, Subject, Message) and hand off a formatted draft straight tohttps://wa.me.... No API key, server, or account required out of the box.Privacy-Safe Page Context & UTM Attribution (
includePageContext)
Automatically appends the page title, URL, and UTM tags (utm_source,utm_medium,utm_campaign)—while stripping query strings and URL hashes by default so sensitive auth tokens in URLs never leak into chat logs. (Tip: Click the playground link above and submit a test message to see theutm_source=devtoattribution in action!)-
Teams, Timezone Business Hours & Smart Defaults
- Pass an
agentsarray for an accessible department picker (Sales, Support, Billing) with avatars or initials. - Timezone-aware
businessHoursbuilt on nativeIntl.DateTimeFormat(zeromomentordayjsbloat)—automatically preselecting the first online agent.
- Pass an
Optional Live In-Widget Chat & Webhook Transport (
v0.8.0)
Want visitors to stay on your site instead of leaving for the WhatsApp app? Switchtransportto live mode usingcreateWebhookTransport(whatsapp-chat-widget-react/adapters) to connect n8n, Make, Zapier, or a WhatsApp Cloud API proxy—complete withsessionStoragepersistence, delivery statuses, retry handling, and a "Continue on WhatsApp" escape hatch.-
Bring-Your-Own-AI (
v0.8.0— Zero SDK Bloat)
Connect any/v1/chat/completionsendpoint (OpenAI, Claude via OpenRouter/LiteLLM, Cloudflare AI Gateway, Groq, Ollama) viacreateOpenAICompatibleAI:- "Polish with AI" button inside the textarea (with instant Undo).
- Auto-routing & FAQ deflection (
routeAndTriage) that routes to the right agent or answers common questions in-widget. - Private by design: Phone numbers are never sent in AI triage or webhook payloads, and everything fails open so visitors are never blocked.
Popup-Blocker Safe Lead Capture (
webhookUrl)
Fires non-blocking JSON lead payloads vianavigator.sendBeacon(withfetchkeepalivefallback) right as the user submits. If an async AI or webhook step consumes the browser's click activation, the widget automatically renders an "Open WhatsApp" button instead of getting swallowed by a popup blocker.Programmatic Control (
useWhatsAppWidget())
Trigger the widget from any pricing calculator, navbar CTA, or page button usingopenWithDraft({ subject: 'Enterprise Plan', message: '...' }).
Quick Start: React / TypeScript
npm install whatsapp-chat-widget-react import { WhatsAppChat } from 'whatsapp-chat-widget-react'; export function App() { return ( <WhatsAppChat phoneNumber="+2348000000000" title="Support Team" includePageContext theme="auto" /> ); } Quick Start: Plain HTML / No-React (dist/standalone.global.js)
Using plain HTML, Webflow, Shopify, or Squarespace? Drop in the zero-dependency script tag via jsDelivr or unpkg (complete with Shadow DOM isolation and Subresource Integrity):
<script src="https://jsdelivr.net" data-phone="+2348000000000" data-title="Support Team" data-include-context="true" defer ></script> Links & Docs
- Interactive Playground: https://mcdavidobioha.github.io/whatsapp-chat-widget-react-typescript
- GitHub Repository: https://github.com/mcdavidobioha/whatsapp-chat-widget-react-typescript
- Full Feature Breakdown: FEATURES.md
- npm Package: https://www.npmjs.com/package/whatsapp-chat-widget-react
Feedback, stars, issues, and PRs are welcome!
