Skip to main content
Using the v1 widget (Chat Embed @1.x.x)? Widgets created in the CometChat Dashboard now use v2 (@cometchat/chat-embed@2.x.x). On npm, v2 is published under the next tag — latest and a bare package name still resolve to v1 — and existing embeds that load @1.x.x keep running v1 until you change the script tag. Please upgrade to v2. In a future update, v2 will become the default (latest) version on npm and v1 will be marked as legacy. Before you upgrade, read Upgrade from v1 to v2: v2 renames CSS classes, so custom CSS and JavaScript may need updating.
Add the CometChat Widget by pasting one small HTML snippet. It drops in like any other embed—copy the code, paste it into your page, then tell the widget how people should sign in. Choose the sign-in option that matches your site:

Anonymous Chat (Guest Mode)

  • Let anyone chat anonymously without signing up or logging in.
  • Perfect for marketing pages, help centers, or demo sites.

Create + Log In User On The Fly

  • Use your existing user IDs (email, username etc.) to create and log in users automatically.
  • No backend needed—CometChat creates users the first time they visit.

Backend-Created User (Auth Token Login)

  • Create your users via server and login them using secure auth token on frontend.
  • Ideal for sites with existing login systems and backends.

1. Anonymous Chat (Guest Mode)

Use this when:
  • Anyone should be able to start chatting instantly
  • You do not have (or do not want) your own login form yet

Copy this into <head>

Copy this into <body>

Update these values

2. Create + Log In User On The Fly

Use this when:
  • Every person already has an ID inside your product (email, username etc.)
  • You want that ID to drive their chat identity automatically

Copy this into <head>

Copy this into <body>

Update these values

3. Backend-Created User (Auth Token Login)

Use this when:
  • People sign in through your backend, and you generate their CometChat auth token server-side.
Server-side flow (auth token login):
  1. Authenticate the user in your app.
  2. If it’s their first time, call Create User (https://www.cometchat.com/docs/rest-api/users/create) — you can also request an auth token in that call.
  3. For returning users, call Create Auth Token (https://www.cometchat.com/docs/rest-api/auth-tokens/create) to issue a fresh token.
  4. Send the token to the browser and place it in the widget config below.
  5. The same token works for the CometChat Widget, UI Kit, or SDK.
Full walkthrough: How to properly log in and create users in CometChat.

Copy this into <head>

Copy this into <body>

Update these values


Custom text and languages

localization replaces any text in the widget, and can register a language the widget does not ship with. Pass a language code mapped to the keys you want to change — anything you leave out keeps its built-in text.

Adding a language the widget does not ship

Register the code under localization and select it with language. Any key you do not supply falls back to English.
Language codes are matched exactly, then fall back to English — there is no base-language step. A language of "fr-ca" does not pick up "fr"; register "fr-ca" itself, or select "fr".
Invalid input is skipped rather than throwing: a language whose value is not an object, and any key whose value is not a string, are ignored with a console warning naming what was dropped. Keys the widget does not recognise are kept — they are reported in the console, and remain in place if a later release introduces them.