Repository navigation
Features
Mcdavid Obioha edited this page Dec 2, 2026
·
1 revision
Everything whatsapp-chat-widget-react does, as of v0.8.0, with a link to the page that documents each part. Every feature is optional and off by default unless marked default.
Docs: Getting Started · Props Reference
- Floating launcher and contact form. A button opens a name, subject and message form. Default.
-
WhatsApp handoff, no backend. The draft opens in WhatsApp through
https://wa.me/<number>?text=.... No API key, server or account needed. Default. -
Phone number validation. International format, 7 to 15 digits, optional
+. An invalid number disables sending and shows a notice. -
Custom message template.
messageTemplate(details)controls the exact text sent to WhatsApp. -
Configurable form. Hide the
nameorsubjectfield withfields, pre-fill withdefaultMessage, rename the title, hint, button and submit text. -
Zero runtime dependencies. React is a peer dependency (18 or 19). ESM only. TypeScript types included. Client component (
"use client").
Docs: Styling and Theming · Right-to-Left and Translations
-
Variants and sizes.
variant:pilloricon.size:sm,md,lg. -
Themes.
green,brand,light,dark, andauto(the panel follows the visitor's light or dark setting). -
Accent color.
accentColortakes any CSS color. -
CSS variables.
--wa-primary,--wa-bg,--wa-text,--wa-radius,--wa-z-index. -
Position and offset.
bottom-right,bottom-left, and the direction-awarebottom-endandbottom-start.offsetsets the distance from the edges. -
Greeting bubble and notification dot.
greetingshows a bubble over the closed launcher.showNotificationDotshows a dot until the first open. -
Right-to-left support.
dir="rtl"orauto. Styles use CSS logical properties. -
Style control.
classNameandstyleon the root.injectStyles={false}plusimport 'whatsapp-chat-widget-react/styles.css'to load the CSS yourself. -
Translations.
labelsoverrides every built-in string.
Docs: Agents and Business Hours
-
Multiple agents.
agentsshows an accessible picker with avatars or initials. The chat opens with the selected agent's number. One agent needs no picker. -
Business hours.
businessHoursis timezone-aware (built onIntl.DateTimeFormat, no date library) and shows Online or Offline. Per-agent hours are supported. -
Offline behavior. A custom offline message, and
allowOfflineMessages: falseto block sending outside hours. - Smart default agent. The first agent who is online is preselected.
Docs: Page Context and Attribution
-
Page context.
includePageContextappends the page title, URL (without query or hash), UTM source, medium and campaign, and optionally the referrer to the message. Control characters are stripped. - Privacy by default. Query strings and hashes are never included, so tokens in URLs do not leak.
Docs: Controlling the Widget
-
Delayed reveal.
showAfterwaits a number of milliseconds, a scroll percentage, or both. -
Path rules.
hideOnPathshides the widget on matching paths (*wildcard) and follows client-side navigation. -
Force hide.
hidden. -
Controlled or uncontrolled open state.
isOpen,defaultOpen,onOpenChange,onOpen,onClose.
Docs: Live Chat · Backend Recipes
-
Pluggable transport.
transport="handoff"(default) or aWhatsAppTransportAdapterwithmode: "live". -
Conversation view. After the pre-chat form the panel becomes a
role="log"thread witharia-live="polite", a composer (Entersends,Shift+Enteradds a line), and a delivery status on every message (Sending, Sent, Delivered, Not sent with Retry). -
Session persistence. The conversation survives a page reload through
sessionStorage, keyed bywidgetId. "End chat" clears it. -
Continue on WhatsApp. A button in the live view hands the whole transcript to
wa.meat any time. -
createWebhookTransport(fromwhatsapp-chat-widget-react/adapters). A ready adapter for n8n, Make, Zapier or a WhatsApp Cloud API proxy:{ sendUrl, pollUrl?, pollIntervalMs?, headers? }. Polling de-duplicates replies and pauses while the tab is hidden. - Retry and failure handling. Failed sends are marked and can be retried. A message left "sending" at reload is shown as failed.
Docs: Bring Your Own AI · Backend Recipes
- No SDKs, no keys. The widget only calls functions you provide.
-
Polish with AI.
ai.polishMessage(draft, pageContext)adds a button once the visitor has typed 10 characters, with a loading state and an Undo that restores their own words. Failures leave the text unchanged. -
createOpenAICompatibleAI. Fromwhatsapp-chat-widget-react/adapters: connectsaito any/v1/chat/completionsendpoint (OpenAI, Claude through OpenRouter or LiteLLM, Cloudflare AI Gateway, Groq, Ollama) withendpoint,model,headers,systemPromptandenableRouting. Point it at your own proxy; the docs include copy-paste ones. - Private by design. The triage payload carries agent id, name and role only, never phone numbers.
-
Auto-routing.
ai.routeAndTriage(...)can returnsuggestedAgentId. A matching agent is selected and a "Routed to Support" badge is shown. -
Instant replies. If
instantReplyis returned, it is shown with "That solved it" and "Still need a human on WhatsApp".onDeflectionreports the choice. -
Refined messages.
refinedMessagereplaces the text that is sent. - Fails open. If your function throws, the visitor is sent through unchanged.
Docs: Lead Webhooks
-
Non-blocking webhook.
webhookUrlsendsname,subject,message,selectedAgent,pageContext,utmandtimestampas JSON usingnavigator.sendBeacon, falling back tofetchwithkeepalive. It completes even while the page moves to WhatsApp. - Never blocks the visitor. Webhook failures are silent.
-
onBeforeHandoff. Runs before WhatsApp opens. An async callback is awaited for up to 1.5 seconds; its errors are ignored. -
No phone numbers in payloads.
selectedAgentcarries only id, name and role. - Popup-blocker safe. With no async steps, WhatsApp opens synchronously on submit. If an async step used up the browser's click activation, an "Open WhatsApp" button appears instead of a blocked popup.
Docs: Widget Hook and Provider
-
WhatsAppWidgetProvideranduseWhatsAppWidget().{ isOpen, open, close, toggle, openWithDraft }. -
openWithDraft({ name?, subject?, message?, agentId? }). Opens the widget, fills the fields, selects the agent and focuses the first empty field. Calls made before the widget is visible run when it appears. -
Optional.
<WhatsAppChat />works without the provider. -
Tree-shakeable. The provider adds under 0.5 kB,
createWebhookTransport0.7 kB andcreateOpenAICompatibleAI1.2 kB, only when imported.
Docs: Script-Tag Build
-
One file.
dist/standalone.global.js, from unpkg or jsDelivr, no dependencies. Works on plain HTML, WordPress, Webflow, Shopify and Squarespace. -
No JavaScript needed. Configure with
data-*attributes (data-phone,data-theme, ...), JSON for objects (data-agents), or onedata-configobject. -
Global API.
WhatsAppChatWidget.init(config),open(),close(),toggle(),openWithDraft(),destroy()and theisOpenproperty. -
Style isolation. Renders in a Shadow DOM by default so site CSS cannot break it.
shadowDom: falseopts out, with a duplicate-safe style tag. - Same widget. Identical markup and styles as the React component, with a test that compares the two.
-
Also supported: agents, business hours, page context,
showAfter,deepLink(whatsapp://send),onSubmit,webhookUrl,onBeforeHandoff. -
Also in the script build:
ai(withWhatsAppChatWidget.createOpenAICompatibleAI) andonDeflection. -
Not yet in the script build:
transport(live chat).
Docs: Accessibility
- Keyboard operable end to end.
Escapecloses and returns focus to the launcher. Focus moves into the form on open. - Real labels,
aria-expandedandaria-controlson the launcher,role="alert"androle="status"for messages, a namedrole="log"for live chat. - Built-in themes meet WCAG AA contrast, checked by script. Status is always text, never only a color.
- axe-core runs in the test suite on the form, live chat, AI toolbar and instant reply.
Docs: Framework Guides
- A client component (
"use client"). Business hours and page context are computed after mount, so server and client markup match and there are no hydration warnings. - Follows client-side navigation for
hideOnPaths.
-
llms.txtandAGENTS.mddescribe the API for coding assistants. -
props.schema.jsonis generated from the TSDoc on the props, so it cannot drift from the code. - Complete TypeScript types for every prop, callback payload and adapter.
- 126 tests (Vitest, Testing Library, jsdom, node:test), including a React-versus-script DOM parity check.
-
Size budgets in CI with
size-limit, per entry point. - Provenance. Published from GitHub Actions through npm trusted publishing, with a provenance statement.
- Subresource Integrity hashes documented for the CDN build.
-
Backend recipes in
docs/ai-and-webhooks.md: Claude and OpenAI proxies for Next.js and Cloudflare Workers, plus n8n and WhatsApp Cloud API setup. - MIT licensed.
- No built-in LLM, no API keys, no hosted backend. Live chat and AI call your endpoints.
- No tracking or cookies. Live chat uses
sessionStorageonly, and only when you enable it. - No phone numbers in webhook payloads.