Widget bridge reference
The Notifizz widget exposes a programmatic command/event surface —BRIDGE_COMMANDS for sending instructions to the widget, BRIDGE_EVENTS for listening to its state. The three frontend SDKs (@notifizz/react, @notifizz/angular, @notifizz/vanilla) all wrap this same surface; this page documents it directly so you can integrate the widget from any runtime.
TL;DR
window.notifizz(command, ...args)— invoke a bridge command.window.addEventListener("notifizz:ready", cb)— fires once when the widget is loaded and authenticated.window.addEventListener("notifizz:state", cb)— fires on every state change withevent.detail: NotifizzState.- The contract lives in
sdk/shared/contract.ts— single source of truth for both the widget and every SDK.
Public commands
BRIDGE_COMMANDS are the public, supported instructions. They’re the same across React, Angular, and Vanilla.
| Command | Args | Description |
|---|---|---|
authenticateWithFirebase | { apiKey, token, ...userFields? } | Authenticate the widget session with a Firebase ID token. |
authenticateWithBackendToken | { apiKey, token, userId, userEmail, ...additional? } | Authenticate with an HMAC token minted server-side. |
authenticateWithNone | { apiKey, userId, userEmail } | Dev-only — no token verification. |
setPosition | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | Move the bell to one of four screen corners. |
setNotificationCenterStyles | { marginTop?: string } | Adjust the notification-center dropdown placement. |
setBellStyles | { marginRight?: string; marginLeft?: string } | Adjust bell placement. |
toggle | none | Toggle the dropdown open/closed. |
open | none | Open the dropdown. |
close | none | Close the dropdown. |
getState | (state: NotifizzState) => void | Read the current state synchronously via callback. |
A few internal commands (e.g.
setBellIcon, setRoundedButton) live in a separate internal registry and are not part of BRIDGE_COMMANDS. They’re used by the SDK packages and may change without notice — don’t call them from your code.Public events
BRIDGE_EVENTS are dispatched on window:
| Event | Payload (event.detail) | Description |
|---|---|---|
notifizz:ready | none | Fires once when the widget is loaded and authenticated. After this, state.isReady === true. |
notifizz:state | NotifizzState | Fires on every state change. Subscribe to keep your UI in sync. |
NotifizzState
The state object delivered through notifizz:state and via the getState callback:
| Property | Type | Description |
|---|---|---|
isReady | boolean | true once the widget has loaded and authenticated. |
isOpen | boolean | true when the dropdown is open. |
unreadCount | number | Current unread notification count. |
lastUpdated | number | Timestamp (ms) of the last state change. |
hasError | boolean? | true if the widget hit an auth or network error. |
errorCode | string? | Error identifier when hasError is true. |
STATE_FIELDS in the contract) are always present; hasError and errorCode appear only when the widget enters an error state.
Lifecycle ordering
A typical session flows like this:Building your own integration
If you need a framework Notifizz doesn’t ship a SDK for (Vue 3 with composables, Solid, Svelte 5, …), the bridge is enough. Minimal recipe:- Inject the widget script (
https://widget.notifizz.com/v1/widget.js) — use a<script>tag or your framework’s lifecycle hook. - Wait until
typeof window.notifizz === "function". - Call
window.notifizz("authenticateWith…", options)with your auth fields. - Listen for
notifizz:readyto know when the widget is live. - Listen for
notifizz:stateto drive any UI you build around the widget. - Call
window.notifizz("toggle" | "open" | "close")from your own UI elements.
FAQ
Read unread count without rendering the default bell.
Read unread count without rendering the default bell.
Listen for
notifizz:state and read state.unreadCount. Hide the default bell with CSS or by passing a custom render in your SDK (renderBell in React, #customBellIcon in Angular, setBellElement(el) in Vanilla).`getState` returns `isReady: false` immediately after script load.
`getState` returns `isReady: false` immediately after script load.
Expected — authentication is async. Call
getState from inside notifizz:ready, or wait for the first notifizz:state event whose detail.isReady === true.Command before `notifizz:ready` — what happens?
Command before `notifizz:ready` — what happens?
Dropped silently. The widget queues
authenticateWith… calls but not toggle / open / close. Always gate your commands on state.isReady to avoid surprises.Multiple widgets on the same page — supported?
Multiple widgets on the same page — supported?
No, the widget is a singleton bound to
window.notifizz. To switch users, destroy the current instance (via your SDK’s destroy() method) and re-mount with new auth. Two simultaneous identities aren’t supported today.See also
Notification Center overview
Lifecycle, state model, custom bell, headless mode.
React SDK
Idiomatic React wrapper around the bridge.
Vanilla JS SDK
Reference implementation of a bridge consumer.
Authentication overview
The four widget auth modes and when to pick each.