Enbbox Docs

React SDK

Enbbox React SDK (@enbbox/react) — drop-in Inbox component, notification hooks, and real-time updates for React applications.

The @enbbox/react SDK provides React components for embedding notifications in your application.

Installation

npm install @enbbox/react

Components

<Inbox />

The main notification inbox component with bell icon, notification list, and preferences.

import { Inbox } from "@enbbox/react";

<Inbox projectId="YOUR_PROJECT_ID" subscriberId="user-123" />;

Hooks

useNotifications

Access notification data and actions:

import { useNotifications } from "@enbbox/react";

function NotificationList() {
  const { notifications, isLoading, hasMore, fetchMore, readAll } =
    useNotifications({ read: false });

  if (isLoading) return <p>Loading...</p>;

  return (
    <div>
      <button onClick={readAll}>Mark all read</button>
      {notifications?.map((n) => (
        <div key={n.id}>{n.body}</div>
      ))}
      {hasMore && <button onClick={fetchMore}>Load more</button>}
    </div>
  );
}

useCounts

Get notification counts for one or more filters:

import { useCounts } from "@enbbox/react";

function Badge() {
  const { counts } = useCounts({ filters: [{ read: false }] });
  const unread = counts?.[0]?.count ?? 0;
  return unread > 0 ? <span>{unread}</span> : null;
}

On this page