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.

whatsapp-chat-widget-react demo: pick an agent, fill the form, polish the message with AI, and see the exact WhatsApp message

👉 Try the Interactive Live Playground | ⭐ GitHub Repository | 📦 npm Package

What Makes whatsapp-chat-widget-react Different?

  1. 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 to https://wa.me.... No API key, server, or account required out of the box.

  2. 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 the utm_source=devto attribution in action!)

  3. Teams, Timezone Business Hours & Smart Defaults

    • Pass an agents array for an accessible department picker (Sales, Support, Billing) with avatars or initials.
    • Timezone-aware businessHours built on native Intl.DateTimeFormat (zero moment or dayjs bloat)—automatically preselecting the first online agent.
  4. Optional Live In-Widget Chat & Webhook Transport (v0.8.0)
    Want visitors to stay on your site instead of leaving for the WhatsApp app? Switch transport to live mode using createWebhookTransport (whatsapp-chat-widget-react/adapters) to connect n8n, Make, Zapier, or a WhatsApp Cloud API proxy—complete with sessionStorage persistence, delivery statuses, retry handling, and a "Continue on WhatsApp" escape hatch.

  5. Bring-Your-Own-AI (v0.8.0 — Zero SDK Bloat)
    Connect any /v1/chat/completions endpoint (OpenAI, Claude via OpenRouter/LiteLLM, Cloudflare AI Gateway, Groq, Ollama) via createOpenAICompatibleAI:

    • "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.
  6. Popup-Blocker Safe Lead Capture (webhookUrl)
    Fires non-blocking JSON lead payloads via navigator.sendBeacon (with fetch keepalive fallback) 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.

  7. Programmatic Control (useWhatsAppWidget())
    Trigger the widget from any pricing calculator, navbar CTA, or page button using openWithDraft({ 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

Feedback, stars, issues, and PRs are welcome!