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

thesquare-chat-widget

v1.2.15

Published

TheSquareAI accommodation booking chat widget for React / Next.js

Readme

thesquare-chat-widget

TheSquareAI accommodation booking chat widget for React / Next.js.

Connects to your /enquiry/chat backend and handles the full booking conversation flow — T1 welcome → T2 follow-up → T3 confirmation card → T4 enquiry received — out of the box.

Install

npm install thesquare-chat-widget

Usage

Minimal

import { ChatWidget } from 'thesquare-chat-widget';

<ChatWidget apiUrl="https://your-backend.com/enquiry/chat" />

With booker info

import { ChatWidget } from 'thesquare-chat-widget';

<ChatWidget
  apiUrl="https://your-backend.com/enquiry/chat"
  bookerInfo={{
    booker_name:           session.user.name,
    booker_email:          session.user.email,
    booker_contact_number: session.user.phone,
  }}
/>

Booker details are passed as props — they always appear on the booking summary card regardless of what the bot collects during conversation.


Full config

import { ChatWidget } from 'thesquare-chat-widget';

<ChatWidget
  apiUrl="https://your-backend.com/enquiry/chat"
  bookerInfo={{
    booker_name:           'Jane Doe',
    booker_email:          '[email protected]',
    booker_contact_number: '+44 7700 900123',
  }}
  title="TheSquareAI"
  subtitle="Accommodation Assistant · Online"
  position="bottom-right"
  accentColor="#E8344E"
  defaultOpen={false}
/>

Next.js

Wrap in a 'use client' component since the widget uses React state:

'use client';
import { ChatWidget } from 'thesquare-chat-widget';

export default function Layout({ children }) {
  return (
    <>
      {children}
      <ChatWidget apiUrl="https://your-backend.com/enquiry/chat" />
    </>
  );
}

Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | apiUrl | string | Yes | — | Your /enquiry/chat backend URL. | | bookerInfo | { booker_name?, booker_email?, booker_contact_number? } | No | — | Booker details shown on the booking summary card. | | title | string | No | "TheSquareAI" | Widget header title. | | subtitle | string | No | "Accommodation Assistant · Online" | Widget header subtitle. | | position | "bottom-right" \| "bottom-left" | No | "bottom-right" | FAB & panel position. | | accentColor | string (hex) | No | "#E8344E" | Primary brand colour. | | defaultOpen | boolean | No | false | Open the widget on mount. |


Chat flow

| Template | Triggered when | Renders | |----------|---------------|---------| | T1 | Widget opens | Greeting + list of required fields | | T2 | Some fields collected | Acknowledgement + remaining missing fields | | T3 | All fields collected | Booking summary card + Confirm / Edit buttons | | T4 | User confirms | Reference number + next steps + property results |

After T4, the widget collects optional guest details (name, email, phone + country code) and preferences (amenities, pet, parking, accessibility, special note). If the user skips everything, the session ends silently with no API call.

Expected API shape

Request

{
  "session_id": "abc-123",
  "message": "user input here",
  "user_profile": {
    "name": "Jane",
    "email": "[email protected]",
    "phone": "+44...",
    "phone_country_code": "+44",
    "is_guest": true
  }
}

session_id and user_profile are only sent when available. user_profile is populated from bookerInfo on the initial welcome call.

Response

{
  "session_id": "abc-123",
  "template": "T1",
  "follow_up_needed": true,
  "data": { ... }
}

CSS isolation

The widget is fully isolated — host app styles do not affect the widget and the widget does not leak styles into the host app. All styles are scoped to .sq-panel and use an explicit system font stack.


TypeScript

Types are included — no @types/ package needed.

import type { ChatWidgetProps, BookerInfo } from 'thesquare-chat-widget';

Publishing a new version

cd packages/chat-widget
# bump version in package.json, then:
npm run build
npm publish