
<CourierInbox />— full-featured inbox for displaying and managing messages<CourierInboxPopupMenu />— popup menu version of the inbox<CourierToast />— toast notifications for time-sensitive alerts<CourierPreferences />— notification preferences center for managing topic subscriptions and deliveryuseCourier()— hook for programmatic access and custom UIs
Installation
Available on GitHub and npm. Courier publishes two React packages:@trycourier/courier-react for React 18+ and @trycourier/courier-react-17 for React 17.
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.Your client calls your backend
GET https://your-awesome-app.com/api/generate-courier-jwt).Your backend calls Courier
Your backend returns the JWT to your client
Development testing with cURL
To quickly test JWT generation for development only, you can call the Issue Token Endpoint directly.Quick Start
Get up and running with Courier React in minutes. This minimal example shows how to add the inbox component to your app.Inbox Component
<CourierInbox />

Default CourierInbox component
signIn:<CourierInboxPopupMenu />

Default CourierInboxPopupMenu component
Tabs and Feeds
Tabs and feeds organize and filter messages in the inbox. A feed is a container that groups related tabs together. Each tab applies filters to show relevant messages.
CourierInbox with many tabs

CourierInbox with many feeds
Handle Clicks and Presses
Styles and Theming
Customize the inbox to match your app with a theme object. You can customize fonts, icons, text, and more.
Courier React Inbox with a custom unread indicator style
defaultLightTheme / defaultDarkTheme provide the default inbox themes, and mergeTheme(baseTheme, overrideTheme) merges two themes with the override taking precedence.
CourierInboxTheme type is below. Every property is optional; only override what you need. It covers the popup trigger button, the inbox window (header, feeds, tabs, actions), the message list (items, scrollbar, menus), and loading/empty/error states.
CourierInboxTheme Reference
CourierInboxTheme Reference
Popup alignment and dimensions

Customizing the popup menu's alignment, position, and dimensions
Fixed height
<CourierInbox /> has a default height of auto. Set a fixed height with the height prop:
Custom Elements
You can customize individual parts of the inbox by passing render props. Each render prop receives typed props and returns aReactNode.
CourierInboxElement, CourierInboxPopupMenuElement) for programmatic access to component methods like removeHeader().
Toast Component
<CourierToast />

Courier Toast component
onReady callback (see props table below) to wait
until the component is fully initialized.Handle Clicks

Courier Toast with action buttons
onToastItemActionClick to handle those clicks.
Styles and Theming

Courier Toast with a custom theme
defaultToastLightTheme / defaultToastDarkTheme for defaults, and mergeToastTheme(baseTheme, overrideTheme) to merge.
Custom Elements
CourierToast Props

Toast component with auto-dismiss enabled
autoDismiss adds a countdown bar to each toast and automatically removes it after the timeout. The countdown bar color is theme-able via autoDismissBarColor in CourierToastTheme.
Using onReady
If toasts display immediately on mount or custom render functions don’t apply correctly, useonReady to wait for full initialization before authenticating:
Preferences Component
<CourierPreferences />
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 React app.
read:preferences and write:preferences scopes. Always generate JWTs on your backend — see Authentication.CourierPreferences Props
Styles and Theming
Pass aCourierPreferencesTheme to lightTheme and/or darkTheme. Themes are merged with the defaults, so you only specify the values you want to override.
defaultPreferencesLightTheme / defaultPreferencesDarkTheme for defaults, and mergePreferencesTheme(mode, overrideTheme) to merge. See the full CourierPreferencesTheme reference.
useCourier Hook
TheuseCourier() hook provides programmatic access to Courier functionality for building custom UIs or integrating Courier features into existing components.
When to use hooks vs components
- Components (
<CourierInbox />,<CourierToast />): Quick integration with default UI - Hooks (
useCourier()): Custom UIs, programmatic control, advanced state management - Both together: Use hooks for state management while components handle rendering
Hook return value
Inbox methods
Toast methods
Preferences methods
Use thepreferences hook to read and update a user’s notification preferences programmatically — for example, to build a custom preferences UI in place of the <CourierPreferences /> component.
read:preferences and write:preferences scopes. Always generate JWTs on your backend — see Authentication.inbox.error and toast.error for error states:
Advanced
Next.js and SSR
Courier Inbox and Toast support Next.js but only render client-side. In Next.js 13+, add'use client' to the top of any file using Courier components.
Troubleshooting
Inbox not updating in real-time
Inbox not updating in real-time
inbox.listenForUpdates() after authentication. This establishes the WebSocket connection required for real-time updates.Messages not loading
Messages not loading
- Not authenticated — ensure
signIn()has been called - Feeds not registered — call
registerFeeds()beforeload() - Network errors — check
inbox.errorfor details - JWT expired — generate a new token
Authentication errors
Authentication errors
- Invalid JWT: Ensure the JWT is generated correctly on your backend
- Expired JWT: JWTs have an expiration time; generate a new one
- Missing scopes: Ensure your JWT includes
inbox:read:messagesandinbox:write:events - Wrong user ID: Verify the
userIdmatches the user the JWT was issued for
TypeScript errors
TypeScript errors
React 17 vs React 18 package mismatch
React 17 vs React 18 package mismatch
- React 18+:
@trycourier/courier-react - React 17:
@trycourier/courier-react-17
Best Practices
- JWT Security: Always generate JWTs server-side. Cache on the client, refresh before expiration (standard:
'1d'), include only necessary scopes. - Performance: Use
canUseCache: true(default) for cached data. UsedatasetIdsto load only needed datasets. Set appropriatesetPaginationLimit()values. The hook’s reactive state updates automatically; avoid triggering unnecessary re-renders. - Testing: Mock
useCourier()in tests to return test data:
EU and regional endpoints
Only needed if your workspace uses the EU datacenter.@trycourier/courier-react re-exports EU_COURIER_API_URLS and getCourierApiUrlsForRegion from @trycourier/courier-js.
https://api.eu.courier.com/auth/issue-token. Full detail: Courier JS — EU and regional endpoints.apiUrls: EU_COURIER_API_URLS instead of getCourierApiUrlsForRegion("eu") if you prefer the frozen preset.





