### Install announcekit-react with yarn Source: https://github.com/announcekitapp/announcekit-react/blob/master/readme.md Install the announcekit-react package using yarn. ```sh yarn add announcekit-react ``` -------------------------------- ### Accessing widget instance with ref.current.instance() Source: https://github.com/announcekitapp/announcekit-react Example usage of the instance() method to access widget internals such as widget.state.ui.unreadCount. ```tsx const widget = await ref.current.instance(); console.log(widget.state.ui.unreadCount); ``` -------------------------------- ### Using ref.current.withWidget in a React component Source: https://github.com/announcekitapp/announcekit-react Example usage of the imperative handle. Creates a ref and calls withWidget to access the widget instance, log it, and open the widget. The AnnounceKit component is rendered with the ref and a widget URL. ```tsx import React from "react"; import AnnounceKit from "announcekit-react"; function App() { const ref = React.useRef(null); const openAndLog = async () => { await ref.current.withWidget(widget => { console.log("widget instance:", widget); return widget.open(); }); }; return (
); } ``` -------------------------------- ### Button to open widget using ref.current.open() Source: https://github.com/announcekitapp/announcekit-react Example usage of the open() method via a ref. An async arrow is also safe: onClick={async () => await ref.current.open()} as shown in readme.md. ```tsx ``` -------------------------------- ### Class component usage Source: https://github.com/announcekitapp/announcekit-react Example of using AnnounceKit inside a class component, as shown in readme.md. Demonstrates embedding the widget within a navigation list. ```tsx import React from "react"; import AnnounceKit from "announcekit-react"; class App extends React.Component { render() { return (
); } } ``` -------------------------------- ### Button to close widget using ref.current.close() Source: https://github.com/announcekitapp/announcekit-react Example usage of the close() method via a ref. ```tsx ``` -------------------------------- ### UnreadBadge component using unread() Source: https://github.com/announcekitapp/announcekit-react Complete React component example that uses the unread() method to display the unread count, including the AnnounceKit widget with a ref and onWidgetUnread callback. ```tsx import React from "react"; import AnnounceKit from "announcekit-react"; function UnreadBadge() { const ref = React.useRef(null); const [count, setCount] = React.useState(0); React.useEffect(() => { ref.current?.unread().then((n: number) => setCount(n)); }, []); return (
ref.current?.unread().then((n: number) => setCount(n)) } > News {count} unread
); } ``` -------------------------------- ### Basic usage with functional component Source: https://github.com/announcekitapp/announcekit-react Minimal example of embedding the AnnounceKit widget in a functional component. The widget URL is passed via the `widget` prop. ```tsx import React from "react"; import AnnounceKit from "announcekit-react"; function Header() { return ( ); } ``` -------------------------------- ### Access widget instance via ref and call control functions Source: https://github.com/announcekitapp/announcekit-react/blob/master/readme.md Use the 'ref' property to access the widget instance and call control functions like open(), close(), unread(), and instance(). The example shows calling unread() and open() in a functional component. ```js function App() { const ref = React.createRef(); React.useEffect(() => { ref.current.unread().then(an => console.log("unread", an)); }); return (
Whats new
) } ``` -------------------------------- ### Consumer usage: useGlobalWidgetEvents hook to subscribe to global widget events Source: https://github.com/announcekitapp/announcekit-react Example of subscribing to widget events globally outside the component's props. It uses window.announcekit?.on to listen for the 'widget-unread' event and cleans up with off on unmount. The window.announcekit object is created by AnnounceKit's first render. ```tsx import React from "react"; // Subscribe to widget events globally, outside of the component's props. // (window.announcekit is created by AnnounceKit's first render.) export function useGlobalWidgetEvents() { React.useEffect(() => { const win = window as any; const handler = (event: any) => { console.log("widget event:", event); }; win.announcekit?.on("widget-unread", handler); return () => win.announcekit?.off("widget-unread", handler); }, []); } ``` -------------------------------- ### Using unread() in useEffect Source: https://github.com/announcekitapp/announcekit-react Example usage of the unread() method inside a React useEffect hook, logging the unread count. ```js React.useEffect(() => { ref.current.unread().then(an => console.log("unread", an)); }); ``` -------------------------------- ### Using event callbacks and custom launcher style Source: https://github.com/announcekitapp/announcekit-react Shows how to pass event callbacks (onWidgetOpen, onWidgetClose, onWidgetUnread) and customize the launcher with widgetStyle, boosters, and labels. ```tsx import React from "react"; import AnnounceKit from "announcekit-react"; function Newsfeed() { return ( console.log("widget opened")} onWidgetClose={() => console.log("widget closed")} onWidgetUnread={(event) => console.log("unread count", event)} > ); } ``` -------------------------------- ### instance() Source: https://github.com/announcekitapp/announcekit-react Returns a Promise that resolves to the raw widget instance object, or undefined if the widget does not exist yet. Useful for reaching widget SDK internals (e.g., widget.conf, widget.state, widget.open()). ```APIDOC ## instance() ### Description Returns a Promise that resolves to the raw widget instance object, or undefined if the widget does not exist yet. Useful for reaching widget SDK internals (e.g., widget.conf, widget.state, widget.open()). ### Method instance ### Parameters None ### Return A `Promise` resolving to the raw widget instance object, or `undefined` if the widget does not exist yet. ### Example ```tsx const widget = await ref.current.instance(); console.log(widget.state.ui.unreadCount); ``` ``` -------------------------------- ### instance() method signature Source: https://github.com/announcekitapp/announcekit-react Returns a Promise resolving to the raw widget instance object, or undefined if the widget does not exist yet. Useful for reaching widget SDK internals (e.g., widget.conf, widget.state, widget.open()). ```tsx instance(): any ``` -------------------------------- ### instance Source: https://github.com/announcekitapp/announcekit-react Returns the underlying widget instance. Uses withWidget to retrieve the widget object. ```APIDOC ## instance ### Description Returns the underlying widget instance. Uses withWidget to retrieve the widget object. ### Method instance(): any ### Parameters None ### Response Returns a Promise that resolves with the widget instance. ``` -------------------------------- ### instance() Source: https://github.com/announcekitapp/announcekit-react/blob/master/readme.md Returns the underlying widget instance. This method is accessible via the component's ref. ```APIDOC ## instance() ### Description Returns the underlying widget instance. This method is called on the component instance obtained via a ref. ### Method `instance()` ### Returns The widget instance object. ``` -------------------------------- ### Effective widget SDK configuration payload pushed to announcekit queue (src/index.tsx:172-215) Source: https://github.com/announcekitapp/announcekit-react Pushes the exact payload handed to the widget SDK on every initialization. Includes `selector` set to the wrapper DOM node, hard-coded `version: 2`, `framework: "react"`, `framework_version: "2.0.0"`, and a unique `react_symbol` used by `onInit` to destroy stale instances. `onInit` drains `widgetHandlers`, stores the widget in `widgetRef`, and destroys non-matching widgets. `embed` is `!!embedWidget`. ```tsx announcekit.push({ ...customConfig, selector: elementRef.current, version: 2, framework: "react", framework_version: "2.0.0", react_symbol: widgetSymbol, line: { style: floatWidget ? {} : { ...widgetStyle }, }, badge: { style: floatWidget ? {} : { ...widgetStyle }, }, float: { style: { ...widgetStyle }, }, onInit: (w: any) => { if (w.conf.react_symbol !== widgetSymbol) { return w.destroy(); } widgetHandlers.current.forEach((x: any) => x(w)); widgetHandlers.current = []; widgetRef.current?.destroy(); widgetRef.current = w; }, boosters, widget, lang, labels, user_token, embed: !!embedWidget, name, user, data, }); ``` -------------------------------- ### open() method signature Source: https://github.com/announcekitapp/announcekit-react Opens the widget. Takes no parameters and returns undefined because the method body does not return the promise created by withWidget. The wrapped call widget.open() is executed on the underlying widget once it is ready. ```tsx open() ``` -------------------------------- ### open() Source: https://github.com/announcekitapp/announcekit-react/blob/master/readme.md Opens the widget programmatically. This method is accessible via the component's ref. ```APIDOC ## open() ### Description Opens the widget. This method is called on the component instance obtained via a ref. ### Method `open()` ### Example ```js ref.current.open(); ``` ``` -------------------------------- ### withWidget Source: https://github.com/announcekitapp/announcekit-react Invokes a callback with the underlying widget instance. Returns a Promise that resolves with the callback's return value, and safely queues the callback if the widget is not yet initialized. ```APIDOC ## withWidget ### Description Invokes a callback with the underlying widget instance. Returns a Promise that resolves with the callback's return value, and safely queues the callback if the widget is not yet initialized. ### Method withWidget(fn: Function): any ### Parameters - **fn** (Function) - Required - Callback invoked with the underlying widget instance (`widgetRef.current`) ### Response Returns a Promise that resolves with the return value of `fn(widget)`. If the widget is not yet initialized, the callback is queued and invoked later when the widget becomes available. ### Request Example ```tsx import React from "react"; import AnnounceKit from "announcekit-react"; function App() { const ref = React.useRef(null); const openAndLog = async () => { await ref.current.withWidget(widget => { console.log("widget instance:", widget); return widget.open(); }); }; return (
); } ``` ``` -------------------------------- ### open Source: https://github.com/announcekitapp/announcekit-react Opens the AnnounceKit widget. Uses withWidget to call the widget's open method. ```APIDOC ## open ### Description Opens the AnnounceKit widget. Uses withWidget to call the widget's open method. ### Method open() ### Parameters None ### Response No return value. ``` -------------------------------- ### open() Source: https://github.com/announcekitapp/announcekit-react Opens the AnnounceKit widget. This method is called on the imperative handle (ref) and executes the underlying widget's open() method once the widget is ready. ```APIDOC ## open() ### Description Opens the AnnounceKit widget. This method is called on the imperative handle (ref) and executes the underlying widget's open() method once the widget is ready. ### Method open ### Parameters None ### Return `undefined` — the method body does not `return` the promise created by `withWidget`, so `ref.current.open()` resolves to `undefined`. The wrapped call `widget.open()` is executed on the underlying widget once it is ready. ### Example ```tsx ``` ``` -------------------------------- ### globalAnnouncekit() function to create window.announcekit and load SDK Source: https://github.com/announcekitapp/announcekit-react Internal function that ensures a global window.announcekit queue object exists and lazy-loads the AnnounceKit widget SDK script from https://cdn.announcekit.app/widget-v2.js. It is idempotent: the stub is created only once, and subsequent calls return the existing object without appending another script tag. The stub buffers pushes and event subscriptions in a queue until the SDK initializes. ```tsx function globalAnnouncekit() { const win = window as any; if (!win.announcekit) { win.announcekit = win.announcekit || { queue: [], push: function (x: any) { win.announcekit.queue.push(x); }, on: function (n: string, x: Function) { win.announcekit.queue.push([n, x]); }, off: function (name: string, fn: Function) { win.announcekit.on("init", function () { win.announcekit.off(name, fn); }); }, }; let scripttag = document.createElement("script") as HTMLScriptElement; scripttag["async"] = true; scripttag["src"] = `https://cdn.announcekit.app/widget-v2.js`; let scr = document.getElementsByTagName("script")[0]; scr?.parentNode?.insertBefore(scripttag, scr); } return win.announcekit; } ``` -------------------------------- ### withWidget method signature Source: https://github.com/announcekitapp/announcekit-react Signature of the withWidget method. It takes a callback function that receives the underlying widget instance and returns a Promise resolving with the callback's return value. Safe to call before the widget SDK has finished loading. ```tsx withWidget(fn: Function): any ``` -------------------------------- ### useImperativeHandle with withWidget, open, close, instance, unread Source: https://github.com/announcekitapp/announcekit-react Creates the imperative handle for the AnnounceKit component. The handle exposes five methods: withWidget, open, close, instance, and unread. withWidget returns a Promise that resolves with the result of fn(widget); if the widget is not yet initialized, the callback is queued and invoked later when the widget becomes available. ```tsx useImperativeHandle(ref, () => ({ withWidget(fn: Function): any { return new Promise((res) => { if (widgetRef.current) { return res(fn(widgetRef.current)); } else { widgetHandlers.current.push((widget: any) => { res(fn(widget)); }); } }); }, open() { this.withWidget((widget: any) => widget.open()); }, close() { this.withWidget((widget: any) => widget.close()); }, instance(): any { return this.withWidget((widget: any) => widget); }, unread(): number { return this.withWidget((widget: any) => widget.state.ui.unreadCount); }, })); ``` -------------------------------- ### AnnounceKit constructor signature Source: https://github.com/announcekitapp/announcekit-react The component accepts AnnounceKitProps as its only positional argument and an optional ref of type any. The ref receives the imperative handle with methods withWidget, open, close, instance, unread. ```tsx function AnnounceKit(props: AnnounceKitProps, ref: any) ``` -------------------------------- ### Dependency array for useDeepCompareEffect Source: https://github.com/announcekitapp/announcekit-react Used in the push effect to control widget re-initialization. Deep changes to any of these values destroy and re-push the widget; re-renders alone do not trigger re-initialization because the object literal is compared deeply. ```tsx [ { user, data, lang, labels, user_token }, customConfig, widget, name, floatWidget, embedWidget, boosters, loc, ] ``` -------------------------------- ### Event handler wrapper for widget events Source: https://github.com/announcekitapp/announcekit-react Wraps a callback to only invoke it when the event's widget matches the current widget reference. Used internally for event handling. ```tsx const wrapCheck = (handler?: Function) => (event: any) => event.widget === widgetRef.current ? handler?.(event) : null; ``` -------------------------------- ### Derived configuration destructuring from props (src/index.tsx:131-144) Source: https://github.com/announcekitapp/announcekit-react Destructures configuration props, including `boosters` defaulting to `true` when omitted. `embed` is coerced to a boolean with `!!embedWidget`. `widgetStyle` is applied to `float.style` always, but only to `line.style` and `badge.style` when `floatWidget` is falsy. ```tsx const { customConfig, widget, floatWidget, embedWidget, boosters = true, widgetStyle, lang, labels, user_token, name, user, data, } = props; ``` -------------------------------- ### AnnounceKit forwardRef wrapper Source: https://github.com/announcekitapp/announcekit-react The default export is a forwardRef wrapper around the named render function. The ref argument is typed as any and exposes imperative methods (withWidget, open, close, instance, unread). ```tsx function AnnounceKit(props: AnnounceKitProps, ref: any) { // ... } export default forwardRef(AnnounceKit); ``` -------------------------------- ### Generate unique widget symbol for multi-instance protection Source: https://github.com/announcekitapp/announcekit-react Each push generates a unique symbol using Math.random().toString(36).substring(10). The pushed config includes react_symbol: widgetSymbol, and the onInit callback destroys any widget whose w.conf.react_symbol does not match the current symbol, preventing stale/duplicate widgets across re-renders. ```tsx const widgetSymbol = Math.random().toString(36).substring(10); ``` -------------------------------- ### AnnounceKit Component Source: https://github.com/announcekitapp/announcekit-react/blob/master/readme.md The main React component to embed an AnnounceKit widget. It accepts various props for configuration and can be controlled via a ref. ```APIDOC ## AnnounceKit Component ### Description Embed an AnnounceKit widget in your React application. The component renders a launcher element and can be configured with various props. ### Props - **`widget`** (string) - Required - The URL of the widget, obtained from the AnnounceKit Dashboard. - `widgetStyle` (object) - Optional - CSS rules to modify the position of the widget launcher. - `floatWidget` (boolean) - Optional - Set to true if the widget is a float widget. - `embedWidget` (boolean) - Optional - Set to true if the widget is an embed widget. - `boosters` (boolean) - Optional - Set to false to prevent boosters from appearing on the page. - `lang` (string) - Optional - Language selector. - `user` (object) - Optional - User properties for user tracking. - `data` (object) - Optional - Segmentation data. - `labels` (array) - Optional - Filter posts under specific labels or tags. - `user_token` (string) - Optional - JWT token for authentication. - `onWidgetOpen` (function) - Optional - Callback when the widget is opened. - `onWidgetClose` (function) - Optional - Callback when the widget is closed. - `onWidgetResize` (function) - Optional - Callback when the widget is resized. - `onWidgetUnread` (function) - Optional - Callback when the unread post count is updated. ### Example ```jsx Whats new ``` ``` -------------------------------- ### Render wrapper div with inline style and className Source: https://github.com/announcekitapp/announcekit-react The component renders a single wrapper
with an inline style of { display: "inline" }, a className that defaults to "" when not provided, and children inside. The elementRef is passed to the widget SDK as the mount selector. ```tsx return (
{props.children}
); ``` -------------------------------- ### close() method signature Source: https://github.com/announcekitapp/announcekit-react Closes the widget. Takes no parameters and returns undefined, same structure as open(). The underlying widget.close() is invoked once the widget is ready. ```tsx close() ``` -------------------------------- ### close Source: https://github.com/announcekitapp/announcekit-react Closes the AnnounceKit widget. Uses withWidget to call the widget's close method. ```APIDOC ## close ### Description Closes the AnnounceKit widget. Uses withWidget to call the widget's close method. ### Method close() ### Parameters None ### Response No return value. ``` -------------------------------- ### AnnounceKitProps Source: https://github.com/announcekitapp/announcekit-react The AnnounceKitProps type defines the configuration options for the AnnounceKit React widget component. It includes required widget URL and optional properties for styling, event callbacks, user tracking, and custom configuration. ```APIDOC ## AnnounceKitProps ### Description The `AnnounceKitProps` type is the configuration object passed to the `AnnounceKit` component. It includes the required `widget` URL and optional properties for styling, event callbacks, user tracking, and custom configuration. ### Type Definition ```tsx export type AnnounceKitProps = { children?: any; className?: string; widget: string; lang?: string; name?: string; trackLocationChanges?: boolean; onWidgetOpen?: Function; onWidgetClose?: Function; onWidgetResize?: Function; onWidgetUnread?: Function; labels?: string[]; user_token?: string; widgetStyle?: React.CSSProperties; boosters?: boolean; floatWidget?: boolean; embedWidget?: boolean; user?: { id: string; [key: string]: any; }; data?: { [key: string]: any; }; customConfig?: any; }; ``` ### Fields | Field | Type | Required | Description | |-------|------|----------|-------------| | `children` | `any` | no | Content rendered inside the wrapper `
` (typically the launcher trigger) | | `className` | `string` | no | Class name applied to the wrapper `
`; defaults to `""` (`props.className ?? ""`) | | `widget` | `string` | **yes** | URL of the widget, obtained from the AnnounceKit dashboard; passed through to the widget SDK config | | `lang` | `string` | no | Language selector; passed through to the widget SDK config | | `name` | `string` | no | Widget name; passed through to the widget SDK config | | `trackLocationChanges` | `boolean` | no | When set, polls `window.location.href` every 250 ms and re-initializes the widget when it changes | | `onWidgetOpen` | `Function` | no | Called on the SDK `widget-open` event for this widget instance | | `onWidgetClose` | `Function` | no | Called on the SDK `widget-close` event for this widget instance | | `onWidgetResize` | `Function` | no | Called on the SDK `widget-resize` event for this widget instance | | `onWidgetUnread` | `Function` | no | Called on the SDK `widget-unread` event for this widget instance | | `labels` | `string[]` | no | Label/tag filter for displayed posts; passed through to the SDK config | | `user_token` | `string` | no | JWT for user authentication (AnnounceKit JWT setup); passed through to the SDK config | | `widgetStyle` | `React.CSSProperties` | no | CSS rules applied to the widget launcher (`line`, `badge`, and `float` style objects in the pushed config) | | `boosters` | `boolean` | no | Whether boosters appear; defaults to `true` (destructured as `boosters = true`) | | `floatWidget` | `boolean` | no | Marks the widget as a Float widget; when `true`, `line` and `badge` styles are emitted as `{}` | | `embedWidget` | `boolean` | no | Marks the widget as an Embed widget; pushed to the SDK as `embed: !!embedWidget` | | `user` | `{ id: string; [key: string]: any }` | no | User properties for user tracking; requires `id`; passed through to the SDK config | | `data` | `{ [key: string]: any }` | no | Segmentation data; passed through to the SDK config | | `customConfig` | `any` | no | Arbitrary extra config spread first into the pushed SDK config (`...customConfig`), letting consumers set any SDK option not covered by the other props | ``` -------------------------------- ### close() Source: https://github.com/announcekitapp/announcekit-react Closes the AnnounceKit widget. This method is called on the imperative handle (ref) and executes the underlying widget's close() method once the widget is ready. ```APIDOC ## close() ### Description Closes the AnnounceKit widget. This method is called on the imperative handle (ref) and executes the underlying widget's close() method once the widget is ready. ### Method close ### Parameters None ### Return `undefined` — same structure as `open()`; the underlying `widget.close()` is invoked once the widget is ready. ### Example ```tsx ``` ``` -------------------------------- ### unread() method signature Source: https://github.com/announcekitapp/announcekit-react Returns the result of this.withWidget(...), which is a Promise. At runtime this resolves to widget.state.ui.unreadCount (a number), or undefined until the widget is initialized. The readme.md usage confirms the promise semantics. ```tsx unread(): number ``` -------------------------------- ### AnnounceKit (default export) Source: https://github.com/announcekitapp/announcekit-react The default export of the announcekit-react package is a React component that mounts an AnnounceKit widget v2 into the page. It accepts configuration props and exposes imperative control methods through a ref. ```APIDOC ## AnnounceKit (default export) ### Description The default export of the `announcekit-react` package is a React component that mounts an AnnounceKit widget v2 into the page. It accepts configuration props and exposes imperative control methods through a ref. ### Import ```tsx import AnnounceKit from "announcekit-react" ``` ### Constructor (props) The component takes the `AnnounceKitProps` object as its only positional argument. ```tsx function AnnounceKit(props: AnnounceKitProps, ref: any) ``` #### Parameters - **props** (`AnnounceKitProps`) - Required - Widget configuration and event callbacks, see `types.md` - **ref** (`any`) - Optional - Ref receiving the imperative handle (methods `withWidget`, `open`, `close`, `instance`, `unread`) ``` -------------------------------- ### unread Source: https://github.com/announcekitapp/announcekit-react Returns the unread count from the widget's state. Uses withWidget to access the widget's unread count. ```APIDOC ## unread ### Description Returns the unread count from the widget's state. Uses withWidget to access the widget's unread count. ### Method unread(): number ### Parameters None ### Response Returns a Promise that resolves with the unread count (number). ``` -------------------------------- ### close() Source: https://github.com/announcekitapp/announcekit-react/blob/master/readme.md Closes the widget programmatically. This method is accessible via the component's ref. ```APIDOC ## close() ### Description Closes the widget. This method is called on the component instance obtained via a ref. ### Method `close()` ### Example ```js ref.current.close(); ``` ``` -------------------------------- ### AnnounceKitProps type definition Source: https://github.com/announcekitapp/announcekit-react The only named type exported by the package, defined in src/index.tsx:5–37. It configures the AnnounceKit widget, with required `widget` URL and optional props for styling, events, user tracking, and custom config. Callback props are typed as `Function` and receive the SDK event object at runtime. ```tsx export type AnnounceKitProps = { children?: any; className?: string; widget: string; lang?: string; name?: string; trackLocationChanges?: boolean; onWidgetOpen?: Function; onWidgetClose?: Function; onWidgetResize?: Function; onWidgetUnread?: Function; labels?: string[]; user_token?: string; widgetStyle?: React.CSSProperties; boosters?: boolean; floatWidget?: boolean; embedWidget?: boolean; user?: { id: string; [key: string]: any; }; data?: { [key: string]: any; }; customConfig?: any; }; ``` -------------------------------- ### unread() Source: https://github.com/announcekitapp/announcekit-react Returns the unread count from the widget. The source annotates the return type as `number`, but the method actually returns a Promise that resolves to `widget.state.ui.unreadCount` (a number), or `undefined` until the widget is initialized. ```APIDOC ## unread() ### Description Returns the unread count from the widget. The source annotates the return type as `number`, but the method actually returns a Promise that resolves to `widget.state.ui.unreadCount` (a number), or `undefined` until the widget is initialized. ### Method unread ### Parameters None ### Return A `Promise` resolving to `widget.state.ui.unreadCount` (a number), or `undefined` until the widget is initialized. ### Example ```js React.useEffect(() => { ref.current.unread().then(an => console.log("unread", an)); }); ``` ```tsx import React from "react"; import AnnounceKit from "announcekit-react"; function UnreadBadge() { const ref = React.useRef(null); const [count, setCount] = React.useState(0); React.useEffect(() => { ref.current?.unread().then((n: number) => setCount(n)); }, []); return (
ref.current?.unread().then((n: number) => setCount(n)) } > News {count} unread
); } ``` ``` -------------------------------- ### unread() Source: https://github.com/announcekitapp/announcekit-react/blob/master/readme.md Returns the unread post count of the widget. This method is accessible via the component's ref. ```APIDOC ## unread() ### Description Returns a promise that resolves to the unread post count. This method is called on the component instance obtained via a ref. ### Method `unread()` ### Returns Promise resolving to a number (unread count). ### Example ```js ref.current.unread().then(an => console.log("unread", an)); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.