|
| 1 | +# @zickt/react |
| 2 | + |
| 3 | +[](https://www.npmjs.com/package/@zickt/react) |
| 4 | +[](https://bundlephobia.com/package/@zickt/react) |
| 5 | +[](./LICENSE) |
| 6 | +[](https://www.npmjs.com/package/@zickt/react) |
| 7 | +[](https://docs.npmjs.com/generating-provenance-statements) |
| 8 | +[](#quality) |
| 9 | + |
| 10 | +Official React SDK for [Zickt](https://zickt.com) — add a [customer messaging widget](https://zickt.com) to your React app in one line. |
| 11 | + |
| 12 | +[Zickt](https://zickt.com) is a modern customer communication platform for support, sales, and engagement. This package provides React components and hooks for embedding the [Zickt live chat widget](https://zickt.com) into any React application. |
| 13 | + |
| 14 | +## Install |
| 15 | + |
| 16 | +```bash |
| 17 | +npm install @zickt/react |
| 18 | +``` |
| 19 | + |
| 20 | +## Quick Start |
| 21 | + |
| 22 | +```tsx |
| 23 | +import { ZicktMessenger } from '@zickt/react'; |
| 24 | + |
| 25 | +function App() { |
| 26 | + return ( |
| 27 | + <> |
| 28 | + <YourApp /> |
| 29 | + <ZicktMessenger channelKey="your-channel-key" /> |
| 30 | + </> |
| 31 | + ); |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +That's it. The messenger widget loads from Zickt's CDN and appears on your page. Get your channel key from the [Zickt dashboard](https://zickt.com). |
| 36 | + |
| 37 | +## With Hooks |
| 38 | + |
| 39 | +Use `ZicktProvider` and `useZickt` when you need programmatic control — showing/hiding the messenger or reading state. |
| 40 | + |
| 41 | +```tsx |
| 42 | +import { ZicktProvider, useZickt } from '@zickt/react'; |
| 43 | + |
| 44 | +function App() { |
| 45 | + return ( |
| 46 | + <ZicktProvider channelKey="your-channel-key" user={{ email: 'user@example.com', name: 'Jane' }}> |
| 47 | + <Dashboard /> |
| 48 | + </ZicktProvider> |
| 49 | + ); |
| 50 | +} |
| 51 | + |
| 52 | +function Dashboard() { |
| 53 | + const { show, hide, isReady } = useZickt(); |
| 54 | + |
| 55 | + return ( |
| 56 | + <div> |
| 57 | + <button onClick={() => show()}>Open Chat</button> |
| 58 | + <button onClick={() => hide()}>Close Chat</button> |
| 59 | + </div> |
| 60 | + ); |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +## API |
| 65 | + |
| 66 | +### `<ZicktMessenger />` |
| 67 | + |
| 68 | +Drop-in component. Renders nothing visually — the messenger widget is injected by the SDK. |
| 69 | + |
| 70 | +| Prop | Type | Description | |
| 71 | +| ------------------------ | ------------------------- | --------------------------------------------------------- | |
| 72 | +| `channelKey` | `string` | **Required.** Your [Zickt](https://zickt.com) channel key | |
| 73 | +| `user` | `ZicktUser` | Identify the current user | |
| 74 | +| `company` | `ZicktCompany` | Associate a company | |
| 75 | +| `appearance` | `ZicktAppearance` | Position and theme | |
| 76 | +| `hideDefaultLauncher` | `boolean` | Hide the default chat button | |
| 77 | +| `customLauncherSelector` | `string` | CSS selector for a custom launcher element | |
| 78 | +| `onReady` | `() => void` | Called when the messenger is fully loaded | |
| 79 | +| `onShow` | `() => void` | Called when the messenger opens | |
| 80 | +| `onHide` | `() => void` | Called when the messenger closes | |
| 81 | +| `onUnreadCountChanged` | `(count: number) => void` | Called when unread count changes | |
| 82 | + |
| 83 | +### `<ZicktProvider />` |
| 84 | + |
| 85 | +Wraps your app and provides context to `useZickt`. Accepts all the same props as `ZicktMessenger` plus `children`. |
| 86 | + |
| 87 | +```tsx |
| 88 | +<ZicktProvider channelKey="your-channel-key" user={{ email: 'user@example.com' }}> |
| 89 | + {children} |
| 90 | +</ZicktProvider> |
| 91 | +``` |
| 92 | + |
| 93 | +### `useZickt()` |
| 94 | + |
| 95 | +Hook for programmatic control. Must be used inside a `ZicktProvider`. |
| 96 | + |
| 97 | +```tsx |
| 98 | +const { |
| 99 | + isReady, // boolean — true when messenger has loaded |
| 100 | + show, // () => void — open the messenger |
| 101 | + hide, // () => void — close the messenger |
| 102 | + showNewMessage, // (message?: string) => void — open with a pre-filled message |
| 103 | + update, // (config: Partial<ZicktConfig>) => void — update config at runtime |
| 104 | + getVisitorId, // () => string | undefined — get the current visitor ID |
| 105 | + shutdown, // () => void — shut down the messenger |
| 106 | +} = useZickt(); |
| 107 | +``` |
| 108 | + |
| 109 | +## Types |
| 110 | + |
| 111 | +All types are exported for use in your application: |
| 112 | + |
| 113 | +```tsx |
| 114 | +import type { |
| 115 | + ZicktConfig, |
| 116 | + ZicktUser, |
| 117 | + ZicktCompany, |
| 118 | + ZicktAppearance, |
| 119 | + ZicktCallbacks, |
| 120 | + ZicktContextValue, |
| 121 | + ZicktProviderProps, |
| 122 | + ZicktMessengerProps, |
| 123 | +} from '@zickt/react'; |
| 124 | +``` |
| 125 | + |
| 126 | +### `ZicktUser` |
| 127 | + |
| 128 | +```typescript |
| 129 | +interface ZicktUser { |
| 130 | + id?: string; |
| 131 | + email?: string; |
| 132 | + name?: string; |
| 133 | + phone?: string; |
| 134 | + avatar?: string; |
| 135 | + [key: string]: unknown; // custom attributes |
| 136 | +} |
| 137 | +``` |
| 138 | + |
| 139 | +### `ZicktAppearance` |
| 140 | + |
| 141 | +```typescript |
| 142 | +interface ZicktAppearance { |
| 143 | + position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; |
| 144 | + theme?: 'light' | 'dark' | 'auto'; |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +## Resources |
| 149 | + |
| 150 | +- [Documentation](https://zickt.com/docs/channels/messenger/react) — full React SDK reference and guides |
| 151 | +- [Zickt website](https://zickt.com) — create a free account and get your channel key |
| 152 | + |
| 153 | +## Requirements |
| 154 | + |
| 155 | +- React 18 or 19 |
| 156 | +- A [Zickt](https://zickt.com) account and channel key |
| 157 | + |
| 158 | +## Quality |
| 159 | + |
| 160 | +This package enforces strict quality gates on every release: |
| 161 | + |
| 162 | +- **100% test coverage** — statements, branches, functions, lines (48 tests) |
| 163 | +- **Bundle size limit** — under 3 kB minified + brotli |
| 164 | +- **Strict TypeScript** — no `any`, explicit return types, strict boolean expressions |
| 165 | +- **28 ESLint rules** — all as error, including type-aware async/condition correctness |
| 166 | +- **Type validation** — [publint](https://publint.dev), [attw](https://arethetypeswrong.github.io), [tsd](https://github.com/tsdjs/tsd) |
| 167 | +- **npm provenance** — cryptographically signed builds linked to source |
| 168 | + |
| 169 | +## License |
| 170 | + |
| 171 | +[MIT](./LICENSE) |
0 commit comments