360dialog-connect-button

中文文档
1.0.2发布于 2026/08/03MITTypeScriptESM + CJS零依赖近 30 天下载 4.5万

React component to trigger and consume the 360dialog Partner Integrated Onboarding process, as well as the 360dialog Permission Page.

原始使用文档
文档目录11 节
  1. With yarn
  2. With NPM
  3. React Usage
  4. Vanilla JavaScript / HTML Usage
  5. CDN Installation
  6. Basic Example
  7. React Component Styling
  8. Vanilla JavaScript Styling
  9. Using CSS Custom Properties (Recommended)
  10. Available CSS Custom Properties
  11. Using Regular CSS

360dialog Partner Integrated Onboarding

This package provides a button component to quickly integrate the 360dialog Partner Integrated Onboarding process into your application. It supports React.js as an importable component and Vanilla JavaScript / plain HTML via a CDN-hosted web component (<dialog-connect-button>), so you can use it on any website without a build step. To learn more about this process and how to participate in this as a 360dialog Partner, please visit our documentation or contact your account manager. If you want to become a 360dialog Partner in order to enable your clients to use the WhatsApp Business API, please get in touch with us.



Prerequisites

In order to access the 360dialog Partner Integrated Onboarding process you need to set your partner_redirect_url via the Partner API. This will be used to redirect the client after the onboarding process is finished. Important: To use the ConnectButton component the redirect URL needs to match the route, that has the button integrated.



Installation

With yarn

yarn add 360dialog-connect-button

With NPM

npm install 360dialog-connect-button


Getting started

React Usage

Add the connect button to your React app:

import { ConnectButton } from '360dialog-connect-button';

const App = () => {
  const handleCallback = callbackObject => {
    /* The callback function returns the client ID as well as all channel IDs, for which you're enabled to fetch the API key via the Partner API */

    console.log('client ID: ' + callbackObject.client);
    console.log('channel IDs: ' + callbackObject.channels);
  };

  return (
    <div>
      <ConnectButton partnerId={'your-partner-id'} callback={handleCallback} />
    </div>
  );
};

Vanilla JavaScript / HTML Usage

You can also use the connect button on any website without React or npm! Simply include the script from a CDN and use the <dialog-connect-button> HTML element.

CDN Installation

<!-- From unpkg -->
<script src="https://unpkg.com/360dialog-connect-button/dist/dialog-connect-button.umd.js"></script>

<!-- From jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/360dialog-connect-button/dist/dialog-connect-button.umd.js"></script>

Basic Example

<!DOCTYPE html>
<html>
  <head>
    <script src="https://unpkg.com/360dialog-connect-button/dist/dialog-connect-button.umd.js"></script>
  </head>
  <body>
    <dialog-connect-button
      partner-id="your-partner-id"
      label="Connect WhatsApp Business"
    >
    </dialog-connect-button>

    <script>
      document.addEventListener('dialog-connect-callback', event => {
        console.log('Client ID:', event.detail.client);
        console.log('Channels:', event.detail.channels);
      });
    </script>
  </body>
</html>

For more detailed vanilla JavaScript usage examples and API documentation, see VANILLA-USAGE.md.



Properties

Following properties are supported by the button component:

Property nameTypeDescriptionRequired
partnerIdstringYour 360dialog Partner ID✅
callback(callbackObject: {client: string, channels: string[], revokedChannels?: string[]}) => voidCallback function, that receives the returned client ID as well as channel IDs✅
requestedNumberstringOptional parameter to request access for a specific phone number
labelstringOptional parameter to provide a custom button label
queryParameters{email?: string, name?: string, state?: string, redirect_url?: string, next?: string, plan_selection?: string, flow?: string, io_signature?: string, io_timestamp?: string, preverified_phone_number_id?: string}Optional query parameters that get passed to the sign up form for pre-filling
version'v1' | 'v2'Hub version to connect to — v1 uses hub.360dialog.com, v2 uses app.360dialog.com (default: 'v1')
useNewRedirectbooleanUse the new CH IO redirect URL (default: false)


Styling

React Component Styling

The ConnectButton React component is an unstyled <button /> component. You can use any styling method, e.g. CSS-in-JS libraries such as styled-components.

import { ConnectButton } from '360dialog-connect-button';

const App = () => {
  const StyledConnectButton = styled(ConnectButton)`
    outline: none;
    background: #ff4369;
    color: white;
    padding: 8px 16px;
    border-radius: 3px;
    margin-top: 32px;
    border: none;
  `;

  return (
    <div>
      <StyledConnectButton
        partnerId={'your-partner-id'}
        callback={handleCallback}
      />
    </div>
  );
};

Vanilla JavaScript Styling

The <dialog-connect-button> web component can be styled using CSS custom properties (CSS variables) or regular CSS targeting the element.

<style>
  dialog-connect-button {
    --dialog-connect-bg: #007bff;
    --dialog-connect-color: white;
    --dialog-connect-hover-bg: #0056b3;
    --dialog-connect-padding: 12px 24px;
    --dialog-connect-border-radius: 6px;
    --dialog-connect-font-size: 16px;
  }
</style>

<dialog-connect-button
  partner-id="your-partner-id"
  label="Connect WhatsApp Business"
>
</dialog-connect-button>

Available CSS Custom Properties

PropertyDescriptionDefault Value
--dialog-connect-bgBackground color#007bff
--dialog-connect-colorText colorwhite
--dialog-connect-borderBorder stylenone
--dialog-connect-paddingButton padding12px 24px
--dialog-connect-border-radiusBorder radius4px
--dialog-connect-font-sizeFont size14px
--dialog-connect-font-familyFont familySystem fonts
--dialog-connect-transitionCSS transitionall 0.2s ease
--dialog-connect-hover-bgHover background colorDarker variant
--dialog-connect-hover-colorHover text colorSame as base
--dialog-connect-active-bgActive background colorDarker variant
--dialog-connect-disabled-bgDisabled background color#ccc
--dialog-connect-disabled-colorDisabled text color#666

Using Regular CSS

<style>
  .my-connect-button {
    --dialog-connect-bg: #28a745;
    --dialog-connect-hover-bg: #218838;
    --dialog-connect-padding: 14px 28px;
    --dialog-connect-font-size: 18px;
    --dialog-connect-border-radius: 8px;
  }
</style>

<dialog-connect-button
  class="my-connect-button"
  partner-id="your-partner-id"
  label="🚀 Get Started"
>
</dialog-connect-button>

版本与发布记录

360dialog-connect-button 共发布 20 个版本,首次发布于 2022/01/27;过去 12 个月发布了 4 个版本。

版本发布日期距今
1.0.2latest2026/08/033 个月前
1.0.12026/06/234 个月前
1.0.02026/06/234 个月前
0.9.22026/04/087 个月前
0.9.12025/01/021.8 年前
0.9.02023/11/242 年前

关于 360dialog-connect-button 的常见问题

360dialog-connect-button 是什么?

React component to trigger and consume the 360dialog Partner Integrated Onboarding process, as well as the 360dialog Permission Page.

如何安装 360dialog-connect-button?

在项目目录运行 npm install 360dialog-connect-button,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

360dialog-connect-button 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

360dialog-connect-button 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

360dialog-connect-button 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

360dialog-connect-button 可以商用吗?

360dialog-connect-button 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

360dialog-connect-button 的下载量有多少?

根据 npm 官方下载统计,360dialog-connect-button 在 2026/10/04 – 2026/11/02 这 30 天内被下载 45,470 次,日均约 1,516 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

360dialog-connect-button 还在维护吗?

最新版本 1.0.2 发布于 2026/08/03(3 个月前);至今共发布 20 个版本,其中过去 12 个月发布了 4 个;首次发布于 2022/01/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。