Skip to content

Getting Started

Mcdavid Obioha edited this page Dec 2, 2026 · 2 revisions

Getting Started

Requirements

  • 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.

Install

npm install whatsapp-chat-widget-react

Add the widget

Render 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.

Phone number format

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.

What the visitor sees

  1. A green launcher in the bottom-right corner: "Chat on WhatsApp".
  2. Clicking it opens a panel with Name, Subject and Message fields.
  3. "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?

Make it your own

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 }} />

Not using React?

Use the Script-Tag Build: one <script> tag, no build step. It works on WordPress, Webflow, Shopify, Squarespace and plain HTML.

Going further

Upgrading

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.

Clone this wiki locally