Skip to main content

What’s new in React v8+

v8+ is a major update to Courier’s web SDKs. It brings:
  • A redesigned UI with built-in dark mode
  • Themeable components
  • A smaller JavaScript bundle with no third-party dependencies
Pins aren’t yet supported in v8+. A message can’t be pinned to the top of the inbox. If your app needs them, stay on v7 for now.Tags carry over, but the model changed. v7 added and removed a message’s tags from the client. In v8+ a tag is a read filter: you set tags on the send, and a tab shows the messages carrying them.

What’s in this guide

Migration steps for: All three share the same first steps: upgrade dependencies and authentication. After those, skip to Toasts or Preferences if you have no Inbox components to migrate.

Migration steps

1. Upgrade dependencies

v8+ ships as one package: @trycourier/courier-react for React 18+, or @trycourier/courier-react-17 for React 17. The two are identical. The examples below work with either, and your app should install only one. Earlier Courier React SDKs required several packages, such as @trycourier/react-provider and @trycourier/react-inbox. Remove them as part of this migration.
In your app’s package.json, remove existing @trycourier React dependencies:

2. Generate JWTs

Already generating JWTs (JSON Web Tokens) for Courier SDKs? Skip this step.
Earlier Courier React SDKs accepted client keys: a stable, Base64 encoded identifier, with or without an HMAC signature. v8+ replaces them with JWTs, short-lived signed tokens your backend mints with your Courier API key. Client keys no longer authenticate anything, so every app needs a backend endpoint that issues a token. covers minting the token, the scope strings, reading auth state, signing out, and token refresh. Using the EU datacenter? See . Inbox and Toast components need the three required scopes in . Migrating Preferences components too? Add read:preferences and write:preferences.

3. Authenticate the Courier SDK

Replace every <CourierProvider> with one call to courier.shared.signIn(). That method lives on the singleton useCourier() returns. covers signOut and token refresh.
The Courier SDK shares authentication between components, so one call to courier.shared.signIn is enough.Using only Courier toasts? Skip to Upgrade Toast components for the <CourierToast> version of this example.
App.tsx

4. Upgrade Inbox components

4a. Theming

v8+ drops styled-components and themes natively. The theme definition changed. Compare the v7 theme with the types.
App.tsx
Dark mode
React Inbox v8+ switches between light and dark mode automatically, following system preferences.
App.tsx

4b. Custom components

You can override most components in the default UI. Some prop names and method signatures for passing components changed in v8+. See and .
App.tsx
Custom component prop changes
Inbox components:
In v8+, renderHeader receives CourierInboxHeaderFactoryProps, which holds a feeds array, not feedType. Each feed has feedId, title, iconSVG, tabs, and isSelected.

4c. React hooks

Pins aren’t yet supported in v8+, and neither is changing a message’s tags from the client. Reading and filtering by tag both work, through feeds and tabs.
A custom UI fetches messages and holds inbox state itself, with hooks. Courier’s React hooks now ship inside @trycourier/courier-react. Remove any dependency on @trycourier/react-hooks.
package.json
Change useInbox() to useCourier() and update the changed method signatures. The full set of updated hooks follows.
App.tsx

Method signature changes

4d. Feeds and tabs

v8+ adds feeds and tabs for organizing messages. A feed groups related tabs. Each tab is a filtered view of messages within its feed.
  • Feeds group tabs into sections, such as Inbox, Archive, and Notifications.
  • Tabs filter the messages in a feed, such as All, Unread, and Important.
  • Datasets back each tab, identified by a unique datasetId.
A tab’s filter takes tags, status, archived, and from. Set fields are AND’d together, while several tags match as OR. This is where v7’s message tags land: send a message with its tags, then give each tag a tab. For every field, see the . Pass a feeds prop to <CourierInbox> to configure feeds and tabs:
App.tsx
With hooks, register feeds with inbox.registerFeeds() and access messages by datasetId:
App.tsx
In v7, messages were accessed through inbox.messages. In v8+:
  • Messages are organized by datasetId in inbox.feeds[datasetId].messages
  • Use inbox.registerFeeds() to configure feeds and tabs
  • Use inbox.listenForUpdates() to enable real-time updates
  • Use datasetId (not feedType) when calling fetchNextPageOfMessages()
The has the rest.

5. Upgrade Toast components

v8+ includes a redesigned Toast component with more customization, native theming, and dark mode. Migrating from v7 Toast means updating the component usage, its props, and the theme structure. Replace every <CourierProvider> with one call to courier.shared.signIn(). That method lives on the singleton useCourier() returns.
Already authenticated for Courier Inbox? Replace each <CourierProvider>...</CourierProvider> block with <CourierToast>.The Courier SDK shares authentication between components, so one call to courier.shared.signIn is enough.
App.tsx

5a. Toast props

Some <CourierToast> props changed or moved in v8+, alongside new props for theming, custom components, and user interaction.

5b. Theming

v8+ drops the styled-components package and themes natively. The theme definition changed. Compare the v7 theme with the types.
App.tsx
Dark mode
React Toast v8+ themes dark mode fully and switches between light and dark automatically, following system preferences. Every field is in the type.
App.tsx

5c. Custom components

For customization beyond theming, v8+ adds two render props:
  • renderToastItemContent: Customize the content area, keeping the default styles, animations, and dismiss behavior.
  • renderToastItem: Replace the appearance and behavior of the toast items and stack.
See and .

5d. React hooks

A custom UI holds toast state itself, with hooks. Courier’s React hooks now ship inside @trycourier/courier-react. Remove any dependency on @trycourier/react-hooks.
package.json
Change useToast() to useCourier() and update the changed method signatures. The full set of updated hooks follows.
App.tsx

Method signature changes

config and clientKey info are removed from hooks in v8+.

6. Upgrade Preferences components

v8+ replaces the v7 <PreferencesV4> component, from @trycourier/react-preferences, with <CourierPreferences>. It shares the redesigned UI, native theming, and dark mode of the other v8+ components. As with Inbox and Toast, replace <CourierProvider> with one call to courier.shared.signIn(). Already authenticated for another v8+ component? No second sign-in is needed. The SDK shares authentication across components.
Preferences requires a JWT with the read:preferences and write:preferences scopes.
App.tsx

6a. Preferences props

The v7 <PreferencesV4> component accepted only two props, tenantId and draft. It had no theming props. Its colors came from the brand configured on the fetched preference page. Three things change in v8+:
  • Tenant scoping moves to signIn. There is no per-component prop.
  • Draft-preview isn’t yet available.
  • <CourierPreferences> adds native client-side theming and other options.
Set tenantId once on signIn. It scopes both <CourierPreferences> and the headless useCourier().preferences hooks automatically.

6b. Theming

Like Inbox and Toast, v8+ Preferences drops styled-components and themes natively through the lightTheme and darkTheme props. The fields are in .

6c. React hooks

A custom Preferences UI using the v7 usePreferences() hook from @trycourier/react-hooks should move to useCourier().preferences. Courier’s React hooks now ship inside @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.
has the full signatures and a working example.

SDK documentation

Markdown rendering

Courier React 1.13.0 through 7.x.x render Markdown-formatted messages automatically, such as those produced when Markdown Rendering is enabled for the Courier Inbox provider. v8+ has no built-in Markdown rendering. Add it with custom Inbox components, as below with markdown-to-jsx.
package.json
App.tsx

Troubleshooting

Migrate Inbox and Toast together. The v8+ SDK depends on a newer major version of @trycourier/courier-js than v7 does. Two versions on one page isn’t supported. No requests to Courier after upgrading? Two versions of a @trycourier/ package are probably installed at once. Run npm dedupe, yarn dedupe, or your package manager’s equivalent. Still stuck? Open an issue on GitHub or contact Courier Support.