Developers
Start building
Themes/Theme SDK/Modules/inbox/Hooks

Hooks

The hooks of @poltura/theme-sdk/inbox.

On this page
import { … } from '@poltura/theme-sdk/inbox';

useInbox

The chat's view and actions: whether it is open, online or unread, the conversation, the help search and the merchant's wording and look.

useInbox(): InboxState

Call it inside InboxRoot, which exists only where the store offers chat; the default InboxWidget already provides it.

Returns: The chat's view and the actions the shopper can take.

Example

import { InboxRoot, useInbox } from '@poltura/theme-sdk/inbox';

function UnreadDot() {
  const { view, actions } = useInbox();
  if (view.open || view.unread === 0) return null;
  return (
    <button type="button" onClick={actions.open}>
      {view.copy.unread(view.unread)}
    </button>
  );
}

export function ChatNotice() {
  return (
    <InboxRoot>
      <UnreadDot />
    </InboxRoot>
  );
}
Last updated