npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bridge-ai-dev/ecom-chat

v1.0.8

Published

Bridge E-commerce Chat widget integration for Next.js with Litium authentication

Readme

@bridge-ai-dev/ecom-chat

Bridge E-commerce Chat widget integration for Next.js with Litium authentication.

Why This Package?

When integrating a chat widget with Litium e-commerce, you often need access to authentication cookies like .AspNetCore.Identity.Application. However, these cookies are typically HttpOnly, meaning they cannot be accessed from client-side JavaScript for security reasons.

This package solves this problem by:

  1. Creating a secure API route that runs on the server and can access HttpOnly cookies
  2. Providing a React component that fetches these cookies via the API and passes them to the chat widget

Installation

Step 1: Run the Setup Command

In your Next.js project root, run:

npx @bridge-ai-dev/ecom-chat

This will create the API route at app/api/bridge-auth/route.ts.

Step 2: Install the Package

npm install @bridge-ai-dev/ecom-chat

Usage

Basic Usage

Add the ChatComponent to your layout:

// app/layout.tsx
import { ChatComponent } from '@bridge-ai-dev/ecom-chat';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        {children}
        <ChatComponent 
          tenantId="your-tenant-uuid"
          widgetScriptUrl="http://localhost:5173/chat-widget.js"
        />
      </body>
    </html>
  );
}

With Full Widget Configuration

<ChatComponent 
  tenantId="your-tenant-uuid"
  widgetScriptUrl="http://localhost:5173/chat-widget.js"
  accessToken="optional-access-token"
  position="bottom-right"
  backgroundColor="#6366f1"
  foregroundColor="#ffffff"
  size="medium"
  borderWidth={2}
  borderColor="#4f46e5"
  autoPopup={false}
  onAuthSuccess={(authData) => {
    console.log('Auth successful, cart context:', authData.cart_context);
  }}
  onAuthError={(error) => {
    console.error('Auth failed:', error.message);
  }}
/>

Custom API Endpoint

<ChatComponent 
  tenantId="your-tenant-uuid"
  bridgeAuthEndpoint="/api/custom-bridge-auth"  // Custom API route path
  containerId="my-chat-container"                // Custom container ID
/>

Passing Auth Data Directly (No API Route Call)

If you already have access to the identity/cart tokens (e.g. in a Server Component), you can pass them directly:

<ChatComponent 
  tenantId="your-tenant-uuid"
  identity="optional-identity-token"
  cartContext="optional-cart-jwt"
  // ... other props
/>

API Reference

ChatComponent Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | tenantId | string | ✅ | - | Your Bridge Chat tenant identifier | | identity | string | ❌ | - | Identity token (skips API call if provided) | | cartContext | string | ❌ | - | Cart context token (skips API call if provided) | | widgetScriptUrl | string | ❌ | - | URL to the chat widget script (loads dynamically) | | accessToken | string | ❌ | - | Optional access token for authenticated requests | | position | 'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' | ❌ | 'bottom-right' | Widget position on screen | | backgroundColor | string | ❌ | '#6366f1' | Widget background color | | foregroundColor | string | ❌ | '#ffffff' | Widget foreground/text color | | size | 'small' \| 'medium' \| 'large' | ❌ | 'medium' | Widget size | | borderWidth | number | ❌ | 2 | Widget border width in pixels | | borderColor | string | ❌ | '#4f46e5' | Widget border color | | autoPopup | boolean | ❌ | false | Auto popup the chat widget on load | | onAuthSuccess | (authData: BridgeAuthResponse) => void | ❌ | - | Callback when auth bridge succeeds | | onAuthError | (error: Error) => void | ❌ | - | Callback when auth bridge fails | | bridgeAuthEndpoint | string | ❌ | /api/bridge-auth | Custom API endpoint path | | containerId | string | ❌ | bgc-chat-container | Container element ID |

BridgeAuthResponse

interface BridgeAuthResponse {
  cart_context: string | null;
  identity: string | null;
  raw?: string | null;
}

How It Works

┌─────────────────┐      ┌──────────────────┐      ┌─────────────────┐
│  ChatComponent  │ ──▶  │  /api/bridge-auth │ ──▶  │  Chat Widget    │
│  (Client)       │      │  (Server)         │      │  (BridgeChat)   │
└─────────────────┘      └──────────────────┘      └─────────────────┘
        │                        │                         │
        │  1. Fetch cookies      │                         │
        │ ──────────────────────▶│                         │
        │                        │  Server can read        │
        │                        │  HttpOnly cookies       │
        │                        │                         │
        │  2. Return JSON        │                         │
        │ ◀──────────────────────│                         │
        │                        │                         │
        │  3. Initialize with cookies + config             │
        │ ────────────────────────────────────────────────▶│
        │                        │                         │

What Gets Passed to BridgeChat.init()

When the component initializes, it calls BridgeChat.init() with:

BridgeChat.init({
  tenantId: 'your-tenant-uuid',
  backendUrl: 'https://your-backend-api.com',
  accessToken: 'optional-access-token',
  cookies: {
    cart_context: 'value-from-cookie'
  },
  identityCookie: 'value-from-identity-cookie',
  container: 'bgc-chat-container',
  position: 'bottom-right',
  backgroundColor: '#6366f1',
  foregroundColor: '#ffffff',
  size: 'medium',
  borderWidth: 2,
  borderColor: '#4f46e5',
  autoPopup: false
});

Security

  • The API route runs server-side, allowing access to HttpOnly cookies
  • Cookies are passed to the chat widget via JavaScript, not exposed to third parties
  • The component uses credentials: 'include' to ensure cookies are sent with the request

Requirements

  • Next.js 13+ with App Router
  • React 17+

License

MIT