<courier-inbox>: inbox for displaying and managing messages<courier-inbox-popup-menu>: popup menu version of the inbox<courier-toast>: toast notifications for time-sensitive alerts<courier-preferences>: preference center for topic subscriptions and deliveryCourierInboxDatastoreandCourierToastDatastore: the data layer, for custom UIs
Installation
The inbox, toast, and preferences are separate packages, so install only the ones you render.Authentication
Courier authenticates with a JWT that your backend mints with your Courier API key, never in client code. Authenticate users is the full guide: the token flow, scope strings, reading auth state, signing out, and token refresh. Using the EU datacenter? See EU setup.Courier from @trycourier/courier-js. Import it from any one of them and sign in once, and every Courier element on the page uses that session and its real-time connection.
Quick start
Importing a package registers its elements, so the tag renders as soon as the module loads. Sign the user in and the inbox fills.Component reference
Each component’s options, theme, callbacks, and custom-render surface live with the feature. These links open on the Web Components tab.
The
CourierInboxTheme, CourierToastTheme, and CourierPreferencesTheme objects are the same on React, Vue, Angular, and the Web Components, so each is documented once: inbox theme, toast theme, preferences theme.
Attributes and methods
Every option is an HTML attribute, a method on the element, or both. Attributes suit static setup written in markup. Methods suit anything that changes at runtime or takes a function, and they are what the framework SDKs call under the hood.
The inbox, the popup menu, and the preferences element also take
preview, which renders injected data with no sign-in. Pair it with setPreviewData().
Render slots such as setListItem(), selectFeed(), refresh(), and the toast’s onToastItemClick() exist only as methods. Each one is documented on the In-App page for its feature.
A theme attribute must be valid JSON. A malformed light-theme or dark-theme isn’t applied, and the inbox and toast throw a parse error to the console. Build the string with JSON.stringify(), or call setLightTheme() with the object instead.
auto-dismiss turns off only when set to "false". Any other value, including an empty attribute, turns it on, and removing the attribute leaves it on. Call disableAutoDismiss() to turn it off from code.
Events
Besides itsonMessage* methods, <courier-inbox> dispatches a DOM event for each interaction. The detail carries the same payload the method’s handler receives.
<courier-inbox-popup-menu>, or on document. That suits a host that delegates events from one place, or that loads the element before its own code runs.
The message-click, message-action-click, and message-long-press attributes take a function body as a string, the way onclick does, and run it with props in scope. The element compiles it with new Function, so a Content Security Policy without 'unsafe-eval' blocks it. Use the event or the method under a strict CSP.
Typing the elements
Each package exports its element class, so a TypeScript host can type the element it queries and get the methods autocompleted.Advanced
Server-side rendering
Importing a package on the server is safe. The elements register only whenwindow exists, so the import is a no-op under Node, and the tags render once the module runs in the browser. In Next.js, import the package from a client component.
Troubleshooting
The element renders nothing
The element renders nothing
The package isn’t imported on that page, so the browser treats the tag as an unknown element. Import the package (
@trycourier/courier-ui-inbox for the inbox) in a module that runs on that page.A method call throws 'is not a function'
A method call throws 'is not a function'
The script ran before the element was registered. Import the package first, or wait with
await customElements.whenDefined("courier-inbox") before calling methods.Messages not loading
Messages not loading
Possible causes:
- Not authenticated: call
Courier.shared.signIn() - JWT expired: generate a new token
- Missing scopes: include
inbox:read:messagesandinbox:write:eventsin the JWT - Wrong user ID: the
userIdmust match the user the JWT was issued for