Notifications

client.notifications holds the toast notifications to show: errors and other messages the SDK reports. Integrators can also add their own notifications to the store.

Reading

const { notifications } = client.notifications.store.getLatestValue();

// Filtered by severity
const errors = client.notifications.error;

Subscribe to render changes:

const unsubscribe = client.notifications.store.subscribeWithSelector(
  (state) => ({ notifications: state.notifications }),
  ({ notifications }) => renderToasts(notifications),
);

Add and dismiss notifications

const notificationId = client.notifications.addSuccess({
  message: "Settings saved",
  origin: { emitter: "SettingsPage" },
});

client.notifications.remove(notificationId);