ConnectWhatsAppButton
Props, styling and a live ConnectWhatsAppButton example.
Customize
`redirect` (default) navigates this tab, `popup` opens a new tab. Open the popup in the click handler so browsers do not block it.
Replaces navigation, for tests and custom flows.
npm install @polymorfa/react@dev @polymorfa/browser@devimport { PolymorfaProvider, ConnectWhatsAppButton } from "@polymorfa/react";
const appearance = { theme: "light", variables: { colorPrimary: "#635bff" } };
export function ConnectWhatsAppButtonExample() {
return (
<PolymorfaProvider tokenEndpoint="/api/polymorfa/token" appearance={appearance}>
<ConnectWhatsAppButton
target="popup"
>
Connect WhatsApp
</ConnectWhatsAppButton>
</PolymorfaProvider>
);
}ConnectWhatsAppButton from @polymorfa/react. Choose props and styles above; the preview stays visible in every code view.
Props#
childrenReactNodeButton label.
Default "Connect WhatsApp"
onConnect(result: ConnectWhatsAppResult) => voidCalled after the QuickLink is created and opened.
onError(error: unknown) => voidCalled when the QuickLink cannot be created.
classNamestringRoot class and slot classes.
classNamesSlotClassNamesRoot class and slot classes.
target"redirect" | "popup"redirect(default) navigates this tab,popupopens a new tab. Open the popup in the click handler so browsers do not block it.Default
"redirect"open(url: string) => voidReplaces navigation, for tests and custom flows.
Styling#
Use className, classNames (a class for any slot, typed SlotClassNames), appearance variables and element styles. The Style panel applies changes to the live component. See Appearance.
Setup#
Use the provider and server route for your application. The preview above uses local sample data and controllers. Chat controllers and inbox data sources keep your data separate from the UI.