@zean-chat/react 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zean
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # @zean-chat/react: live chat widget for React and Next.js
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Add a free customer support chat to your React app with one component and a hook, with [Zean](https://zean.chat/?utm_source=npm&utm_medium=readme&utm_campaign=react). Works with Next.js, React Router and TanStack Start. Your App key is in your Zean dashboard.
4
+
5
+ ```bash
6
+ npm install @zean-chat/react
7
+ ```
8
+
9
+ ```tsx
10
+ import { ZeanChat, useZean } from "@zean-chat/react";
11
+
12
+ // Once, in the root layout or root route.
13
+ <ZeanChat appKey="app_your_app_key" getToken={user ? fetchZeanToken : undefined} attributes={{ plan: "pro" }} />;
14
+
15
+ // Anywhere.
16
+ const { open, close, toggle, unreadCount, identify, signOut, setAttributes } = useZean();
17
+ ```
18
+
19
+ To switch people, render one time without `getToken` in between. Full guide: [install the chat in React and Next.js](https://zean.chat/docs/install-react), [React reference](https://zean.chat/docs/reference-react).
20
+
21
+ ## Why Zean
22
+
23
+ - Free plan to start. Paid plans in FCFA, payable by Mobile Money.
24
+ - Shared inbox for your team. Reply from your phone.
25
+ - Verified identity, webhooks, French and English. Fast even on 3G.
26
+
27
+ ## Links
28
+
29
+ [Zean live chat](https://zean.chat/?utm_source=npm&utm_medium=readme&utm_campaign=react) · [Documentation](https://zean.chat/docs) · [Create a free account](https://zean.chat/sign-in?utm_source=npm&utm_medium=readme&utm_campaign=react) · [Zean vs Intercom](https://zean.chat/compare/intercom) · [Zean vs Crisp](https://zean.chat/compare/crisp)
30
+
31
+ Other SDKs: [@zean-chat/js](https://www.npmjs.com/package/@zean-chat/js) · [@zean-chat/react](https://www.npmjs.com/package/@zean-chat/react) · [@zean-chat/vue](https://www.npmjs.com/package/@zean-chat/vue) · [@zean-chat/react-native](https://www.npmjs.com/package/@zean-chat/react-native)
@@ -0,0 +1,10 @@
1
+ import type { ZeanChatProps, ZeanControls } from './interfaces.js';
2
+ export type { ZeanAttributes, ZeanLocale, ZeanTokenSource } from '@zean-chat/js';
3
+ export type { ZeanChatProps, ZeanControls } from './interfaces.js';
4
+ /**
5
+ * Shows the chat. Render it once, near the root, on every page. It renders nothing itself: the chat sits in its own
6
+ * frame, and stays across page changes.
7
+ */
8
+ export declare function ZeanChat({ appKey, getToken, attributes, locale, loaderUrl }: ZeanChatProps): null;
9
+ /** Opens and closes the chat, and follows the unread count. Works in any component, before the chat has loaded. */
10
+ export declare function useZean(): ZeanControls;
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ "use client";
2
+
3
+ // src/index.ts
4
+ import { useEffect, useRef, useSyncExternalStore } from "react";
5
+ import { loadZean, zean } from "@zean-chat/js";
6
+ function ZeanChat({ appKey, getToken, attributes, locale, loaderUrl }) {
7
+ const latestToken = useRef(getToken);
8
+ const tokenSource = useRef(() => latestToken.current?.() ?? Promise.resolve(null));
9
+ const identified = useRef(false);
10
+ const signedIn = Boolean(getToken);
11
+ const attributesKey = attributes ? JSON.stringify(attributes) : null;
12
+ useEffect(() => {
13
+ latestToken.current = getToken;
14
+ });
15
+ useEffect(() => {
16
+ loadZean({ appKey, locale, loaderUrl });
17
+ }, [appKey, locale, loaderUrl]);
18
+ useEffect(() => {
19
+ if (signedIn && !identified.current) zean.identify(tokenSource.current);
20
+ else if (!signedIn && identified.current) zean.signOut();
21
+ identified.current = signedIn;
22
+ }, [signedIn]);
23
+ useEffect(() => {
24
+ if (attributesKey) zean.setAttributes(JSON.parse(attributesKey));
25
+ }, [attributesKey]);
26
+ return null;
27
+ }
28
+ var serverUnreadCount = () => 0;
29
+ function useZean() {
30
+ const unreadCount = useSyncExternalStore(zean.onUnreadChange, zean.getUnreadCount, serverUnreadCount);
31
+ return {
32
+ open: zean.open,
33
+ close: zean.close,
34
+ toggle: zean.toggle,
35
+ identify: zean.identify,
36
+ signOut: zean.signOut,
37
+ setAttributes: zean.setAttributes,
38
+ unreadCount
39
+ };
40
+ }
41
+ export {
42
+ ZeanChat,
43
+ useZean
44
+ };
@@ -0,0 +1,14 @@
1
+ import type { ZeanApi, ZeanAttributes, ZeanOptions } from '@zean-chat/js';
2
+ export interface ZeanChatProps extends ZeanOptions {
3
+ /**
4
+ * While a person is signed in: returns a token your server signed. Leave it out when no one is; to switch people,
5
+ * leave it out once in between.
6
+ */
7
+ getToken?: ZeanOptions['getToken'];
8
+ /** What the page knows about the person, shown on the Contact's profile. */
9
+ attributes?: ZeanAttributes;
10
+ }
11
+ /** The chat's methods, and the count of replies the Contact has not seen. */
12
+ export interface ZeanControls extends Omit<ZeanApi, 'getUnreadCount' | 'onUnreadChange'> {
13
+ unreadCount: number;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
- "name": "@zean-chat/react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@zean-chat/react",
3
+ "version": "0.1.0",
4
+ "description": "Live chat widget for React and Next.js: add a free customer support chat to your app with one component and a hook. Intercom and Crisp alternative.",
5
+ "keywords": [
6
+ "react",
7
+ "nextjs",
8
+ "next.js",
9
+ "react-router",
10
+ "tanstack-start",
11
+ "react-component",
12
+ "react-hooks",
13
+ "typescript",
14
+ "live-chat",
15
+ "chat-widget",
16
+ "support-chat",
17
+ "customer-support",
18
+ "customer-service",
19
+ "helpdesk",
20
+ "help-desk",
21
+ "in-app-chat",
22
+ "chat",
23
+ "messaging",
24
+ "zean",
25
+ "intercom-alternative",
26
+ "crisp-alternative",
27
+ "tawk-to-alternative",
28
+ "zendesk-alternative"
29
+ ],
30
+ "homepage": "https://zean.chat/docs/install-react",
31
+ "bugs": {
32
+ "url": "https://zean.chat/contact"
33
+ },
34
+ "author": "Zean (https://zean.chat)",
35
+ "license": "MIT",
36
+ "type": "module",
37
+ "sideEffects": false,
38
+ "exports": {
39
+ ".": {
40
+ "zean-source": "./src/index.ts",
41
+ "types": "./dist/index.d.ts",
42
+ "default": "./dist/index.js"
43
+ }
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "prepublishOnly": "npm run build",
53
+ "build": "node ../../scripts/build-sdk.mjs",
54
+ "check-types": "tsc --noEmit"
55
+ },
56
+ "dependencies": {
57
+ "@zean-chat/js": "^0.1.0"
58
+ },
59
+ "peerDependencies": {
60
+ "react": ">=18"
61
+ },
62
+ "devDependencies": {
63
+ "@types/react": "19.2.14",
64
+ "@zean/config": "*",
65
+ "react": "19.2.5",
66
+ "typescript": "6.0.3"
67
+ }
68
+ }