0.2.1 • Published 7 months ago

@bubl/react v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Bubl React

A React component for embedding the Bubl chat widget in React applications.

Note: This package uses the latest widget implementation with Shadow DOM isolation for complete style isolation and improved performance.

Installation

# npm
npm install @bubl/react

# yarn
yarn add @bubl/react

# pnpm
pnpm add @bubl/react

Usage

Basic Usage

import { BublChat } from '@bubl/react';

function App() {
  return (
    <div>
      {/* Your website content */}

      <BublChat
        websiteId="your-website-id"
        primaryColor="#4F46E5"
        secondaryColor="#FFFFFF"
        position="bottom-right"
        welcomeMessage="Hi there! How can I help you today?"
        headerText="Chat Assistant"
        initiallyOpen={false}
        onReady={() => console.log("Bubl widget is ready")}
      />
    </div>
  );
}

Props

PropTypeDefaultDescription
websiteIdstringRequiredYour website ID from the Bubl dashboard
primaryColorstring"#4F46E5"Primary color for the chat widget (hex code)
secondaryColorstring"#FFFFFF"Secondary color for the chat widget (hex code)
position"bottom-right" | "bottom-left""bottom-right"Position of the chat widget
welcomeMessagestring"Hi there! How can I help you today?"Welcome message displayed when the chat is opened
headerTextstring"Chat Assistant"Text displayed in the header of the chat widget
initiallyOpenbooleanfalseWhether the chat widget should be initially open
onReady() => voidundefinedCallback function called when the widget is ready

Controlling the Widget

You can control the widget programmatically using the global Bubl.api object:

// Open the chat widget
window.Bubl?.api?.open();

// Close the chat widget
window.Bubl?.api?.close();

// Toggle the chat widget
window.Bubl?.api?.toggle();

// Maximize the chat widget to fullscreen
window.Bubl?.api?.maximize();

// Restore the chat widget to normal size
window.Bubl?.api?.restore();

// Toggle between maximized and normal size
window.Bubl?.api?.toggleMaximize();

Custom App URL

By default, the widget loads from https://bublai.com. If you're self-hosting Bubl, you can specify a custom app URL in two ways:

Method 1: Using the apiBaseUrl prop (Recommended)

<BublChat
  websiteId="your-website-id"
  apiBaseUrl="https://your-bubl-instance.com"
/>

Method 2: Using global configuration

// Set custom app URL globally
window.bublConfig = {
  appUrl: "https://your-bubl-instance.com"
};

// Then render the component
ReactDOM.render(
  <BublChat websiteId="your-website-id" />,
  document.getElementById('root')
);

Styling

The Bubl chat widget is designed to be completely non-intrusive and will not affect the styles of your website.

  • Complete isolation: Uses Shadow DOM for perfect style isolation
  • Zero interference: Cannot affect or be affected by your website's styles
  • No global styles: All styles are contained within the Shadow DOM
  • Optimized performance: CSS-in-JS implementation for better performance
  • Transparent background: Clean integration with your design

License

MIT

0.2.1

7 months ago

0.2.0

7 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago