
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
React Inbox v8 does not yet support the following:
- Pins: Pinning a message to the top of the inbox
- Tags: Managing categories of messages
What’s in this guide
This guide includes migration steps for: Both follow the same path to upgrade dependencies and authentication. After those steps, you may skip ahead to Toasts 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
If you’re already generating JWTs (JSON Web Tokens) to authenticate Courier SDKs, you can skip this step.

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().
The Courier SDK shares authentication between components, so only one call to
courier.shared.signIn is needed in an app.If you’re only using Courier toasts, skip ahead to Upgrade Toast Components to see this
authentication example for <CourierToast>.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.Dark Mode
React Inbox v8 improves support for dark mode with automatic switching between light and dark modes based on system preferences.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.Custom Component Prop Changes
Inbox Components:| v7 prop | v8 prop |
|---|---|
renderMessage | renderListItem |
renderNoMessages | renderEmptyState |
renderHeader | renderHeader |
| New in v8 | renderLoadingState |
| New in v8 | renderErrorState |
| New in v8 | renderPaginationItem |
renderPin | Pins are not yet supported in v8 |
renderFooter | The Courier watermark footer is removed in v8. |
4c. React Hooks
Message tags and pins are not yet supported in v8. If your app requires tagging or pinning
we recommend continuing to use v7 at this time.
@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.
Method Signature Changes
| v7 signature | v8 signature |
|---|---|
fetchMessages() | load() |
| New in v8 | setPaginationLimit(limit: number) |
| New in v8 | fetchNextPageOfMessages({ feedType: 'inbox' | 'archive' }) |
getUnreadMessageCount() | Replaced with load() (async, refresh the inbox) and inbox.unreadCount (sync, reads stored state) |
markMessageRead(messageId: string) | readMessage(message: InboxMessage) |
markMessageUnread(messageId: string) | unreadMessage(message: InboxMessage) |
markMessageArchived(messageId: string) | archiveMessage(message: InboxMessage) |
| New in v8 | unarchiveMessage(message: InboxMessage) |
trackClick(messageId: string, trackingId: string) | clickMessage(message: InboxMessage) |
markMessageOpened(messageId: string) | openMessage(message: InboxMessage) |
markAllAsRead() | readAllMessages() |
addTag(messageId: string, tag: string) | Not yet supported in v8 |
removeTag(messageId: string, tag: string) | Not yet supported in v8 |
unpinMessage(messageId: string) | Not yet supported in v8 |
5. Upgrade Toast Components

<CourierProvider> with a single call to courier.shared.signIn(),
a method accessible through the singleton exposed with useCourier().
If you’ve already authenticated for Courier Inbox, you only need to replace blocks of
<CourierProvider>...</CourierProvider> with the <CourierToast> component.The Courier SDK shares authentication between components, so only one call to
courier.shared.signIn is needed in an app.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.
| v7 | v8 | Notes |
|---|---|---|
autoClose | autoDismiss and autoDismissTimeoutMs | In v8, split into two separate props. autoDismiss is a boolean |
defaultIcon | Removed in v8 | In v8, configured via theme object. See theming below |
hideProgressBar | autoDismiss | In v8, progress bar only displays when autoDismiss is enabled |
| New in v8 | dismissButton | Display option for the dismiss button |
onClick | onToastItemClick | Event signature has changed in v8 |
| New in v8 | onToastItemActionClick | Handle an action button click |
position | style | Use React’s CSS-like style prop on <CourierToast> |
theme | lightTheme and darkTheme | v8 introduces separate themes for light and dark modes |
transition | Removed in v8 | Configure custom transitions by implementing renderToastItem |
role | Not yet supported in v8 | |
| New in v8 | renderToastItemContent | Customize the toast item content area. See custom components below |
| New in v8 | renderToastItem | Completely customize the toast items and stack. See custom components 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.
Dark Mode
React Inbox 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.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.
Method Signature Changes
| v7 signature | v8 signature |
|---|---|
toast(message) | toast.addMessage(message: InboxMessage) |
| New in v8 | toast.removeMessage(message: InboxMessage) |
config and clientKey info are removed from hooks in v8.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 through the Help Center.