Skip to main content
Inbox UI Preview The Courier Web Components SDK provides drop-in components for building notification experiences in any JavaScript project:
  • <courier-inbox> — full-featured 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> — notification preferences center for managing topic subscriptions and delivery
This is the latest version of the Courier Web Components SDK, recommended for new and existing apps.Coming from an earlier version? We recommend upgrading — check out the migration guide for the React SDK, which is a thin wrapper around these Web Components and exposes a similar API.

Installation

Inbox, Toast, and Preferences are published as separate packages. Install only the ones you need.
Available on GitHub and npm: Inbox · Inbox · Toast · Toast · Preferences · Preferences The Courier SDKs work with any JavaScript build system and do not require any additional build configuration.
Using React? Check out the Courier React SDK, which provides React components and hooks built on top of these Web Components.

Authentication

To use the SDK, you need to generate a JWT (JSON Web Token) for your user. This JWT should always be generated by your backend server, never in client-side code.
Inbox and Toast share the same Courier.shared authentication instance and connection to the Courier backend. Authenticate once and both components work.

JWT Authentication Flow

1

Your client calls your backend

When your app needs to authenticate a user, your client should make a request to your own backend (ex. GET https://your-awesome-app.com/api/generate-courier-jwt).
2

Your backend calls Courier

In your backend endpoint, use your Courier API Key to call the Courier Issue Token Endpoint and generate a JWT for the user.
3

Your backend returns the JWT to your client

Having received the JWT from Courier, your backend should return it to your client and pass it to the Courier SDK.
See all available user scopes for the Courier APIs.

Development Authentication with cURL

To quickly test JWT generation for development only, you can use cURL to call the Courier Issue Token Endpoint directly.
Do not call the Issue Token API from client-side code. Always keep your Courier API keys secure.

Inbox Web Components


<courier-inbox>

Default Courier Inbox component

Default Courier Inbox component

Importing the Courier SDK registers Courier’s Web Components (<courier-inbox>, <courier-inbox-popup-menu>).
Sample App: See a complete working example in our Vanilla JS Inbox sample app.
If you’re using tenants, you can scope requests to a particular tenant by passing its ID to the signIn request.
For the full reference of sign in parameters, see the Courier JS docs.

<courier-inbox-popup-menu>

Default Courier Inbox Popup Menu component

Default Courier Inbox Popup Menu component

Sample App: See a complete working example in our Vanilla JS Popup Menu sample app.

Tabs and Feeds

Tabs and feeds allow you to organize and filter messages in your inbox. A feed is a container that groups related tabs together. Each tab represents a filtered view of messages.
If there is only one feed, the feed selection dropdown is hidden. If a feed has only one tab, the tab bar is hidden and the unread count appears next to the feed.
Preview of CourierInbox with tabs

CourierInbox with many tabs


Handle Clicks and Presses

Use the onMessageClick(), onMessageActionClick(), and onMessageLongPress() methods to handle clicks and presses in the inbox.
onMessageLongPress() is only applicable on devices that support touch events.

Styles and Theming

The fastest way to style the Courier Inbox to match your app is with a custom theme.
You can customize fonts, icons, text, and more. Check out the CourierInboxTheme reference.
Courier Inbox with a custom unread indicator style

Courier Inbox with a custom unread indicator style

Customizing the popup menu's alignment, position, and dimensions

Customizing the popup menu's alignment, position, and dimensions

Fixed height: <courier-inbox> has a default height of auto. Set a fixed height with the height attribute:

Custom Elements

Customize individual parts of the inbox by passing factory functions that return HTML elements.

Programmatic Control

The <courier-inbox> component exposes methods for programmatic control, allowing you to dynamically manage feeds, tabs, actions, and data refresh.

Feed and Tab Selection

Header Actions

Static Helper Methods


Attribute vs Method Usage

Many configuration options can be set either via HTML attributes or programmatic methods:
  • HTML attributes: Best for initial, static configuration
  • Programmatic methods: Best for dynamic, runtime configuration
Some features are only available via methods (e.g., selectFeed(), refresh(), getFeeds()) and cannot be set via attributes.

Toast Web Components

Toasts are short-lived notifications that notify users and prompt them to take action. The Toast component is connected to the feed of Courier Inbox messages.
Toasts are synced with the Inbox message feed. You can use both components together to provide persistent and temporary notifications.

<courier-toast>

Courier Toast component

Importing @trycourier/courier-ui-toast registers Courier’s Web Components (<courier-toast>).
Sample App: See a complete working example in our Vanilla JS Toast sample app.

HTML Attributes

A note on terminology: toast refers to the entire stack of toasts managed by <courier-toast>, while toast item refers to a single toast displayed for a message.

Toast component with auto-dismiss enabled.

If the auto-dismiss attribute is set, the dismiss button (x) will only be visible on hover and each toast item will automatically be dismissed. A countdown bar is shown to indicate the time remaining before the toast disappears.

Handle Clicks

Courier Toast with action buttons

If a message contains actions, toast items will include a button for each. By default, these buttons do not implement any functionality.
index.html

Styles and Theming

Courier toasts with a custom light theme

index.html
Toast items have a subtle default border: 1px solid #E5E5E5 in light mode and 1px solid #3A3A3A in dark mode. Override it with item.border.

Custom Elements


Programmatic Control


Toast Datastore

CourierToastDatastore is the central repository of Inbox messages from which <courier-toast> listens for messages to display and dismiss. It is a singleton accessed through CourierToastDatastore.shared.

Preferences Web Components

The Preferences component lets your users manage which topics they’re subscribed to and how each topic is delivered (per-channel routing and digest schedules), directly inside your app.
Preferences ship in their own package, @trycourier/courier-ui-preferences (see Installation) — it’s standalone and doesn’t require the inbox or toast packages.

<courier-preferences>

Importing @trycourier/courier-ui-preferences registers the <courier-preferences> Web Component.
Preferences use the same authentication mechanism as the inbox, but the JWT must include the read:preferences and write:preferences scopes.

Preferences HTML Attributes


Preferences Styling and Theming

Set themes programmatically with setLightTheme(), setDarkTheme(), and setMode(). Themes are merged with the defaults, so you only need to specify what you want to override. The default accent color matches the Inbox component for a consistent look.
index.html
Theme utilities are also exported: defaultLightTheme / defaultDarkTheme for the defaults, and mergeTheme(mode, overrideTheme) to merge a partial theme.

Custom Channel Labels

Topics can be delivered over multiple channels. Use setChannelLabels() to rename how those channels appear in the UI.
index.html
The default labels are:

EU and regional endpoints

Only if your workspace uses the EU datacenter: pass EU URLs in Courier.shared.signIn. This package re-exports EU_COURIER_API_URLS and getCourierApiUrlsForRegion from @trycourier/courier-js.
See Courier JS — EU and regional endpoints for hostnames, helpers, and JWT issuance.