SDKs
React SDK
@channlize/react: the floating chat widget, an inline chat, a contact form and hooks for React and Next.js, with theming props.
On this page
@channlize/react (0.10.2) gives you a floating live-chat widget, an inline chat, a contact form, and hooks to build your own UI. Conversations land in your Slack channels, and replies from Slack appear in the widget in real time. React 18 or later.
npm install @channlize/reactAll components call the API from the visitor's browser.
Note
The widget and contact form work on any website until you verify a domain. The widget key (wk_…) is public by design, so these routes are rate limited per IP address. Once you verify a domain, the key only works on your verified domains and localhost.
They use your widget key (wk_…, public) and project ID. Find both under API keys in the dashboard.
Next.js App Router
- The components use state and browser APIs. Render them from a file marked
'use client'and import that file from your server layouts or pages. - Only
NEXT_PUBLIC_variables reach the browser. Put the widget key and project ID there, never the server key. Server-side work likenotify()belongs in route handlers or server actions. - The widget renders after hydration only, so it never causes a hydration mismatch.
NEXT_PUBLIC_CHANNLIZE_WIDGET_KEY=wk_your_widget_key
NEXT_PUBLIC_CHANNLIZE_PROJECT_ID=your-project-id'use client';
import { ChannlizeChat } from '@channlize/react';
export function ChatWidget() {
return (
<ChannlizeChat
config={{
apiKey: process.env.NEXT_PUBLIC_CHANNLIZE_WIDGET_KEY!,
projectId: process.env.NEXT_PUBLIC_CHANNLIZE_PROJECT_ID!,
}}
primaryColor="#2563eb"
chatProps={{ title: 'Acme Support' }}
/>
);
}import type { ReactNode } from 'react';
import { ChatWidget } from './chat-widget';
// Stays a server component: only ChatWidget runs on the client.
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body>
{children}
<ChatWidget />
</body>
</html>
);
}React and Vite
import { ChannlizeChat } from '@channlize/react';
export function App() {
return (
<>
{/* …your app… */}
<ChannlizeChat
config={{ apiKey: 'wk_your_widget_key', projectId: 'your-project-id' }}
primaryColor="#2563eb"
chatProps={{ title: 'Acme Support' }}
/>
</>
);
}ChannlizeChat
The all-in-one floating widget: provider, launcher button and chat window. Render it once near the root. It renders through a portal into document.body, with its styles scoped under .channlize-widget.
| Prop | Type | Default | Description |
|---|---|---|---|
config | ChannlizeConfig | required | { apiKey, projectId, baseUrl?, timeout? }: widget key and project ID. |
position | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'bottom-right' | Corner of the launcher. |
offset | { x?: number; y?: number } | { x: 24, y: 24 } | Distance from the edges, in px. |
primaryColor | string | Accent for the launcher and chat window (hex). | |
theme | 'auto' | 'light' | 'dark' | 'auto' | auto follows prefers-color-scheme. |
defaultOpen | boolean | false | Start with the chat open. |
showOnMobile | boolean | true | Show the launcher under 640px. On phones the chat opens full screen. |
chatProps | SupportChatProps | {} | Passed to the chat window: title, greeting, suggestions… See SupportChat. |
buttonSize | number | 56 | Launcher size, in px. |
buttonColors | { background?, hover?, text? } | primaryColor | Launcher colours. |
buttonElement / buttonIcon | ReactNode | Replace the whole launcher, or just its icon. | |
showBadge / unreadCount | boolean / number | false / 0 | Show your own unread count. Without it, the launcher counts agent replies received while closed. |
zIndex | number | 2147483000 | Stacking order of the widget. |
enableAnimations | boolean | true | Always reduced with prefers-reduced-motion. |
onOpen / onClose | () => void | Open and close callbacks. | |
buttonClassName / chatClassName | string | Extra classes on the launcher and chat container. |
SupportChat
The chat window on its own, sized by its container. Render it inside a ChannlizeProvider. The same props go in ChannlizeChat's chatProps (except autoConnect and onMinimize).
'use client';
import { ChannlizeProvider, SupportChat } from '@channlize/react';
export function HelpPanel() {
return (
<ChannlizeProvider config={{ apiKey: 'wk_your_widget_key', projectId: 'your-project-id' }}>
<div style={{ height: 560 }}>
<SupportChat
title="Acme Support"
suggestions={['Billing question', 'Report a bug']}
allowAttachments
theme="light"
/>
</div>
</ChannlizeProvider>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
title | string | 'Support' | Header title: your team or brand. |
greeting | string | 'Hi there!' | Welcome heading before the first message. |
welcomeMessage | string | 'Ask us anything. We’re here to help.' | Welcome text under the greeting. |
suggestions | string[] | Quick replies on the welcome screen; a click sends one. | |
placeholder | string | 'Write a message…' | Composer placeholder. |
statusText | string | 'Replies in a few minutes' | Shown after "Online" in the header. '' hides it. |
avatarUrl / avatar | string / ReactNode | Logo in the header and on the welcome screen. | |
allowAttachments | boolean | false | Let visitors attach files. |
reactionsEnabled | boolean | the workspace setting | Offer emoji reactions on messages. The API reports whether the workspace allows them; false turns the picker off. A reaction your team adds in the dashboard or in Slack shows on the message either way. |
allowEndChat | boolean | true | "End conversation" in the header menu. |
showTimestamps | boolean | true | Times on messages. |
maxLength | number | 5000 | Maximum message length. |
theme | 'auto' | 'light' | 'dark' | 'auto' | Colour scheme. |
primaryColor / primaryTextColor | string | Accent colour, and the text colour on it (picked for contrast when omitted). | |
locale | string | browser locale | Locale for dates and times. |
labels | Partial<SupportChatLabels> | Override any UI string. Defaults: defaultSupportChatLabels. | |
styles / className | per-part CSSProperties / string | Inline style overrides; they win over the theme. | |
sendButtonText | string | 'Send message' | Accessible label of the send button. |
onMinimize | () => void | Shows a minimize button; Esc calls it. | |
autoConnect | boolean | true | Start the session on mount. |
metadata | Record<string, unknown> | Attached to the conversation (plan, user ID…). | |
persistSession / storageKey | boolean / string | true / channlize_session_<widget key> | Resume the session after a reload (localStorage). |
sessionId | string | Resume a known session. | |
onMessage / onError | (message) => void / (error) => void | New message and failure callbacks. |
Reactions
When the workspace allows reactions, every message gets a picker with the emoji the workspace offers: picking one adds the customer's reaction, picking it again takes it back. A reaction your team adds in the dashboard or in Slack shows on the message in the widget too.
With useChatSession, each message carries the reactions of that message (ChatMessage.reactions: the emoji, how many people reacted, whether the customer is one of them, and who they are), and toggleReaction(messageId, emoji, add) adds or removes the customer's own reaction.
Satisfaction rating
When the workspace has CSAT turned on for the widget, the chat asks the customer to rate the conversation from 1 to 5, with an optional comment, once it's closed: by the visitor, or by your team resolving it while the chat is open. The customer can change the rating for 7 days. Nothing to configure in the component.
Coming soon
The rating prompt ships in the next minor release of @channlize/react, with getRating and rateConversation on @channlize/core's client for your own UI.
ContactForm
A themed, accessible contact form that files a conversation in Slack: inline validation, loading, success and error states, an optional topic select and company field, and a honeypot spam guard. Render it inside a ChannlizeProvider.
'use client';
import { ChannlizeProvider, ContactForm } from '@channlize/react';
export function ContactSection() {
return (
<ChannlizeProvider
config={{
apiKey: process.env.NEXT_PUBLIC_CHANNLIZE_WIDGET_KEY!,
projectId: process.env.NEXT_PUBLIC_CHANNLIZE_PROJECT_ID!,
}}
>
<ContactForm
theme="auto"
primaryColor="#2563eb"
fields={{ company: 'optional' }}
topics={['Sales', 'Support', { value: 'billing', label: 'Billing' }]}
onSuccess={(res) => console.log('Filed as', res.conversationId)}
onError={(err) => console.error(err.message)}
/>
</ChannlizeProvider>
);
}The API accepts a message of 10 to 10,000 characters and an optional subject up to 200. When the subject is blank, Channlize uses the topic, then the first line of the message. The topic, company and customFields values are sent as customFields and shown on the Slack post (at most 20 fields).
| Prop | Type | Default | Description |
|---|---|---|---|
onSuccess | (response: CreateContactResponse) => void | Called with { success, conversationId, message }. | |
onError | (error: Error) => void | Called when sending fails. | |
theme | 'auto' | 'system' | 'light' | 'dark' | 'light' | auto and system follow prefers-color-scheme. |
primaryColor / primaryTextColor | string | Accent colour (button, focus ring) and the text colour on it. | |
variant | 'card' | 'plain' | 'card' | card draws a themed surface; plain inherits your page. |
unstyled | boolean | false | Skip the built-in stylesheet; class names stay for your own CSS. |
fields | { name?, company?, subject?, topic? } | name required, subject optional, company hidden | Each 'required' | 'optional' | 'hidden'. Email and message are always required. |
topics | Array<string | { value, label? }> | Options of the topic select, shown only when set. | |
defaultValues | Partial<ContactFormValues> | Initial values, e.g. a topic from ?topic=sales (matched case-insensitively). | |
customFields | Array<{ name, label, type, required?, options?, placeholder? }> | [] | Extra inputs; type is 'text' | 'email' | 'textarea' | 'select'. |
labels | Partial<ContactFormLabels> | Override any string. Defaults: defaultContactFormLabels. | |
submitText / successMessage | string | 'Send message' / 'Thanks for reaching out. We’ll get back to you by email.' | Shortcuts for labels.submit and labels.successMessage. |
minMessageLength / maxMessageLength | number | 10 / 5000 | Client-side length checks. |
honeypot | boolean | true | Hidden field; bots that fill it get a fake success. |
showSuccessState | boolean | true | Show the built-in success state after sending. |
idPrefix | string | 'channlize' | Prefix of field ids (channlize-email). |
styles / className | { form, field, label, input, textarea, button, error, success } / string | Inline styles per part (they win over the theme), extra class on the form. |
A submission opens a Slack thread like a chat message does, labelled 📝 Contact form (chats are 💬 Live chat); the dashboard shows the same source on each conversation. The sender gets an automatic "we got your message" email.
Replies by email
The sender has left your site, so your replies to a contact-form conversation, in the Slack thread or from the dashboard, are emailed to them:
- From "
Support via Channlize", with the subject Re: <their subject or topic>. The email quotes their original message and threads under the automatic reply. - Reply-To is your organization's Billing and contact email (dashboard Settings), so their answer reaches that inbox. Channlize has no inbound address per organization yet: answers don't come back into the conversation, so keep that inbox monitored.
- Quick replies are batched: replies sent within 30 seconds of each other go out as one email.
- Delivery shows in the dashboard: each reply is marked Emailed ✓ or Email failed, and the reply box says where the reply goes. A failure also posts a note in the Slack thread, and the first email of a conversation posts one saying where replies go.
- Never emailed: live-chat conversations (replies show in the widget), internal notes, test conversations, and senders without a real address (placeholders,
.invalidand GitHubnoreplyaddresses).
Hooks
All hooks need a ChannlizeProvider above them.
| Hook | Returns | Use it for |
|---|---|---|
useChatSession(options) | { session, messages, isConnecting, isConnected, error, sendMessage, startSession, endSession, reconnect } | Live chat state for your own UI. Options as in SupportChat; autoConnect defaults to false here. |
useContactForm({ onSuccess, onError }) | { submit, isSubmitting, isSuccess, error, reset } | A headless contact form. |
useChannlizeAnalytics() | { track(name, options) } | Log tracking from the browser, with the widget key. |
useChannlize() | { client, config } | The @channlize/core client behind the provider. |
'use client';
import { useState } from 'react';
import { useChatSession } from '@channlize/react';
// Your own chat UI; render inside <ChannlizeProvider>.
export function MiniChat() {
const { messages, sendMessage, isConnected, error } = useChatSession({
autoConnect: true, // start a session on mount (the hook defaults to false)
metadata: { plan: 'Pro' },
});
const [text, setText] = useState('');
return (
<form
onSubmit={async (e) => {
e.preventDefault();
await sendMessage(text);
setText('');
}}
>
<p>{isConnected ? 'Online' : 'Connecting…'}</p>
<ul>
{messages.map((m) => (
<li key={m.id}>
<b>{m.author === 'agent' ? (m.authorData?.name ?? 'Support') : 'You'}:</b> {m.content}
</li>
))}
</ul>
{error && <p role="alert">{error.message}</p>}
<input value={text} onChange={(e) => setText(e.target.value)} />
<button type="submit" disabled={!isConnected || !text}>Send</button>
</form>
);
}'use client';
import { useChannlizeAnalytics, useContactForm } from '@channlize/react';
// Render inside <ChannlizeProvider>.
export function PricingQuestion() {
// Log tracking from the browser (shown under Log tracking)
const { track } = useChannlizeAnalytics();
// Headless contact form: your own fields, Channlize's submission state
const { submit, isSubmitting, isSuccess, error } = useContactForm({
onSuccess: (res) => console.log('conversation', res.conversationId),
});
return (
<button
type="button"
disabled={isSubmitting || isSuccess}
onClick={async () => {
await track('cta_clicked', { properties: { section: 'pricing' } });
await submit({
name: 'Ada',
email: 'ada@example.com',
subject: 'Pricing',
message: 'Do you offer yearly discounts?',
});
}}
>
{isSuccess ? 'Sent' : error ? error.message : 'Ask about pricing'}
</button>
);
}useChatSession reconnects its real-time stream on its own. Call reconnect() only after it reports a failed stream (error.code === 'SSE_ERROR').
Dashboard appearance
Each widget key can carry an appearance set in the dashboard (Integration → API keys → Appearance). ChannlizeChat and SupportChat read it once per page and use each value only when you didn't pass the matching prop, so an integration that sets its props in code looks the same as before.
| Dashboard field | Prop it fills in |
|---|---|
| Primary colour | primaryColor (and the launcher's buttonColors.background) |
| Launcher position | position on ChannlizeChat |
| Greeting | greeting |
| Welcome text | welcomeMessage |
| Logo URL | avatarUrl |
- If the key is unknown or inactive, or the request fails, the built-in defaults apply.
- When the launcher's colour or position comes from the dashboard,
ChannlizeChatkeeps the launcher hidden until the appearance arrives (at mostappearanceWaitMs, 1.5 s by default), so it doesn't jump. loadAppearance={false}skips the request.- Saved changes reach a returning visitor within about a minute.
"Powered by Channlize"
The chat shows a small "Powered by Channlize" line under the composer. On the Business plan, turn on Hide "Powered by Channlize" in the widget's Appearance to remove it. The server decides: the line is hidden only when the widget asks for it and the plan includes white-labeling, so a prop can't hide it. showBranding forces it on. With loadAppearance={false} there's no request, so it shows. This needs @channlize/react 0.9.0.
Theming
Every component supports light and dark, an accent colour, and inline style overrides. Text on the accent colour is picked for contrast unless you set it.
'use client';
import { ChannlizeChat } from '@channlize/react';
export function ThemedWidget() {
return (
<ChannlizeChat
config={{ apiKey: 'wk_your_widget_key', projectId: 'your-project-id' }}
theme="auto" // 'auto' (follows the OS) | 'light' | 'dark'
primaryColor="#0f766e"
position="bottom-left"
offset={{ x: 16, y: 16 }}
chatProps={{
primaryTextColor: '#ffffff',
avatarUrl: '/logo.png',
statusText: 'Replies within an hour',
locale: 'fr-FR',
labels: { online: 'En ligne', endChat: 'Terminer' },
}}
/>
);
}- Translate or reword any string with
labels; start fromdefaultSupportChatLabelsordefaultContactFormLabels. ContactFormdefaults totheme="light"; the chat defaults toauto.- Need full control?
ContactForm unstyledkeeps the class names and drops the stylesheet, or build on the hooks.
Exports
Components: ChannlizeProvider, ChannlizeChat, SupportChat, ContactForm. Hooks: useChannlize, useChatSession, useContactForm, useChannlizeAnalytics. Values: defaultSupportChatLabels, defaultContactFormLabels. Types: ChannlizeChatProps, SupportChatProps, SupportChatLabels, ChatTheme, ContactFormProps, ContactFormLabels, ContactFormTheme, ContactFieldMode, ContactFormTopic, ContactFormValues, ContactFormCustomField, UseChatSessionOptions, UseChatSessionReturn, plus the core types re-exported from @channlize/core.