
What’s new in React v8+
v8+ of the Courier React SDK is a major update to Courier’s web SDK ecosystem. The latest update features:- A re-designed, modern UI by default with built-in dark mode support
- Fully theme-able and customizable components
- A much smaller JavaScript bundle with no third-party dependencies
What’s in this guide
This guide includes migration steps for: All follow the same path to upgrade dependencies and authentication. After those steps, you may skip ahead to Toasts or Preferences if you don’t need to migrate Inbox components.Migration Steps
1. Upgrade Dependencies
Courier React v8+ is available as a single package@trycourier/courier-react for React 18+
or @trycourier/courier-react-17 for React 17 support. The two packages contain the same
functionality: the examples below work with either, and only one should be used in your app.
Earlier versions of the Courier React SDKs required multiple packages (e.g. @trycourier/react-provider and @trycourier/react-inbox),
which you should remove from your dependencies as part of this migration.
package.json, remove existing @trycourier React dependencies:
2. Generate JWTs
Courier React v8+ requires JWTs to authenticate connections to the Courier backends. JWTs are short-lived, signed tokens used to securely authenticate and authorize requests. They are the recommended way to connect to the Courier backend in all cases. Earlier verions of the Courier React SDKs accepted client keys (a stable Base64 encoded identifier) with or without an HMAC signature. JWT generation requires a private key and should be done in an environment where that key can be accessed securely, like your backend. A typical production JWT generation flow might look like this:
1
Your app calls your backend
When your app needs to authenticate a user, your app
should make a request to your own backend (ex.
GET https://my-awesome-app.com/api/generate-courier-jwt).2
Your backend calls Courier
In your backend, 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 app
Having received the JWT from Courier, your backend should return it to your app and pass it to the Courier SDK.
Testing JWTs in Development
To quickly get up and running with JWTs in development, you can use cURL to call the Courier Issue Token Endpoint directly.3. Authenticate the Courier SDK
Replace instances of<CourierProvider> with a single call to courier.shared.signIn(), a method accessible through
the singleton exposed with useCourier().
App.tsx
4. Upgrade Inbox components
4a. Theming
v8+ removes the dependency on styled-components and supports theming natively. A few examples of how the theme definition has changed are below. For a complete reference while migrating, see the v7 theme and the v8+ theme types.App.tsx
Dark Mode
React Inbox v8+ improves support for dark mode with automatic switching between light and dark modes based on system preferences.App.tsx
4b. Custom Components
Most components in the default UI can be overridden with custom components. Some prop names and method signatures to pass components have changed in v8+. An example is shown here. See the Courier React docs for more examples of using custom components and customizing user interactions in React v8+.App.tsx
Custom Component Prop Changes
Inbox Components:
Note: In v8+,
renderHeader receives CourierInboxHeaderFactoryProps which contains a feeds array (not feedType). Each feed has feedId, title, iconSVG, tabs, and isSelected properties.
4c. React Hooks
Use cases with custom UIs may require fetching messages and maintaining the inbox state manually via hooks. Courier’s React hooks are now included in@trycourier/courier-react.
Remove any dependency on @trycourier/react-hooks.
package.json
useInbox() to useCourier() and update changed method signatures.
A few common examples are shown here. The full set of updated hooks is below.
App.tsx
Method Signature Changes
4d. Feeds and Tabs
v8+ introduces a new feeds and tabs system for organizing messages into logical groups and filtered views. A feed is a container that groups related tabs together. Each tab represents a filtered view of messages within a feed. What’s New:- Feeds: Organize tabs into logical sections (e.g., “Inbox”, “Archive”, “Notifications”)
- Tabs: Provide filtered views of messages (e.g., “All”, “Unread”, “Important”)
- Datasets: Each tab corresponds to a dataset identified by a unique
datasetId
feeds prop to <CourierInbox> to configure feeds and tabs:
App.tsx
inbox.registerFeeds() and access messages by datasetId:
App.tsx
inbox.messages. In v8+:
- Messages are organized by
datasetIdininbox.feeds[datasetId].messages - Use
inbox.registerFeeds()to configure feeds and tabs - Use
inbox.listenForUpdates()to enable real-time updates - Use
datasetId(notfeedType) when callingfetchNextPageOfMessages()
5. Upgrade Toast Components

<CourierProvider> with a single call to courier.shared.signIn(),
a method accessible through the singleton exposed with useCourier().
App.tsx
5a. Toast Props
Some props passed to<CourierToast> to configure behavior have changed or moved in v8+.
Below is the mapping from v7 to v8+. Props for theming, custom components, and
handling user interaction are detailed below.
5b. Theming
v8+ removes the dependency on thestyled-components package and supports theming natively.
A few examples of how the theme definition has changed are below. For a complete reference
while migrating, see the
v7 theme
and v8+ theme types.
App.tsx
Dark Mode
React Toast v8+ improves support for dark mode with fully customizable theming and automatic switching between light and dark modes based on system preferences. For a complete reference while migrating, see the Courier React v8+ theme type.App.tsx
5c. Custom Components
v8+ introduces two render props to use components when your integration requires customization beyond theming:renderToastItemContent: Customize the content area while keeping the default styles, animations, and dismiss functionality.renderToastItem: Customize the complete appearance and behavior of the toast items and stack.
5d. React Hooks
Use cases with custom UIs may require maintaining the toast state manually via hooks. Courier’s React hooks are now included in@trycourier/courier-react.
Remove any dependency on @trycourier/react-hooks.
package.json
useToast() to useCourier() and update changed method signatures.
Example usage and the full set of updated hooks
is below.
App.tsx
Method Signature Changes
config and clientKey info are removed from hooks in v8+.6. Upgrade Preferences Components
Courier React v8+ replaces the v7<PreferencesV4> component (from @trycourier/react-preferences) with <CourierPreferences>, which shares the redesigned UI, native theming, and dark mode support of the other v8+ components.
Authenticating the SDK for Preferences
As with Inbox and Toast, replace <CourierProvider> with a single call to courier.shared.signIn(). If you’ve already authenticated for another v8+ component, no additional sign-in is needed — the SDK shares authentication across components.
App.tsx
6a. Preferences Props
The v7<PreferencesV4> component only accepted two props — tenantId and draft. It had no theming props; its colors were derived internally from the brand configured on the fetched preference page. In v8+, tenant scoping moves to signIn (there’s no per-component prop), draft-preview is not yet available, and <CourierPreferences> adds native client-side theming and other options.
6b. Theming
Like Inbox and Toast, v8+ Preferences removes the dependency onstyled-components and supports theming natively through lightTheme and darkTheme props. See the full CourierPreferencesTheme reference for the available fields.
6c. React Hooks
Custom preferences UIs that used the v7usePreferences() hook from @trycourier/react-hooks should migrate to useCourier().preferences.
Courier’s React hooks are now included in @trycourier/courier-react. Remove any dependency on @trycourier/react-hooks.
App.tsx
Method Signature Changes
config and clientKey info are removed from hooks in v8+. Tenant scoping moves from a per-call tenantId argument to signIn.v7 Documentation
Documentation for v7 and below of the Courier React SDKs can be found at:- React.js SDK Documentation
- Inbox for React.js Web SDK
- Inbox for JavaScript Web Components SDK
- Inbox Views
Markdown Rendering
Courier React versions 1.13.0 through 7.x.x automatically render Markdown-formatted messages, such as those output when Markdown Rendering is enabled for the Courier Inbox provider. v8+ of the Courier React SDK does not include Markdown rendering support by default, however it can be implemented with custom Inbox components. The following example uses themarkdown-to-jsx package.
package.json
App.tsx
More Information
Questions, answers, and troubleshooting info that may come up while migrating. Can I migrate one of Inbox or Toasts without migrating the other? You must migrate both at the same time. The React v8+ SDK depends on a newer major version of the @trycourier/courier-js SDK than previous Courier React SDKs. Running both versions on the same page is not recommended and may result in unexpected issues. I don’t see any requests to the Courier backend after upgrading. This may be caused by multiple versions of the upgraded packages installed at once. Make sure only the latest version of each @trycourier/ package is installed. You may need to runnpm dedupe, yarn dedupe or the equivalent command for your
package manager to remove older conflicting versions. See
github.com/@trycourier/courier-web/issues/92
for more information.
If you have more questions while upgrading, please open an issue on
GitHub or reach out to
Courier Support.