Skip to main content
The Conversation List + Message View layout provides a familiar two‑panel experience, similar to WhatsApp Web or Slack. Users browse conversations on the left and chat in real time on the right.

User Interface Overview

Two-panel conversation list and message view
This layout includes:
  1. Sidebar (Conversation List) – Users and groups
  2. Message View – Real-time messages for the selected conversation
  3. Message Composer – Input for sending text and media

Prerequisites

  • Astro project set up
  • React integration added to Astro
  • CometChat credentials
1

Create or open an Astro project

If you already have the sample astro-conversation project, open it instead.
2

Add React and install CometChat UI Kit

Add your CometChat credentials to .env at the project root:
Use Auth Tokens in production instead of Auth Keys.
3

Initialize CometChat (src/lib/cometchat-init.js)

Create src/lib/cometchat-init.js and initialize the UI Kit using environment variables.
src/lib/cometchat-init.js
4

Build the React island (src/components/ChatApp.jsx)

Create the island used by Astro to render the two‑panel chat. This component mirrors the sample in astro-conversation.
src/components/ChatApp.jsx
5

Render the page (src/pages/index.astro)

Import the island and styles, then hydrate the component on the client.
src/pages/index.astro
The CSS files globals.css and cometchat-layout.css are included in the sample. Ensure your layout CSS sets a two‑panel flex container and sizes the sidebar.
6

Run and verify

Open your app and verify you can select conversations on the left and exchange messages on the right.

Troubleshooting

Ensure the component is rendered as a React island (client:only=\"react\") so it runs only in the browser.
Verify .env contains PUBLIC_COMETCHAT_APP_ID, PUBLIC_COMETCHAT_REGION, and PUBLIC_COMETCHAT_AUTH_KEY, and restart the dev server after changes.
The sample uses ensureLogin(uid) to switch users by logging out if the active UID differs. Update PUBLIC_COMETCHAT_LOGIN_UID for development.

Next Steps

  • Customize styles in src/styles/cometchat-layout.css
  • Add presence or typing indicators
  • Explore themes and component overrides in the UI Kit
To build other experiences (One‑to‑One or Tab‑based), reuse src/lib/cometchat-init.js and switch the React island component.