Skip to main content
Embed Courier’s preference management directly in your app with the Courier React SDK (@trycourier/courier-react). Use the prebuilt <CourierPreferences> component for a themed, drop-in UI, or the headless useCourier().preferences hooks to build your own. Either way, changes sync with Courier’s preference system in real time.

Install

The SDK ships as a single package. Use @trycourier/courier-react for React 18+, or @trycourier/courier-react-17 for React 17. Both expose the same API.

Authentication

Preferences authenticate with a JWT, not a client key. Generate the token server-side with the read:preferences and write:preferences scopes, then sign in once with courier.shared.signIn. Authentication is shared across every Courier component, so if you’ve already signed in for Inbox or Toast, you don’t need to sign in again.
To scope preferences to a tenant, pass tenantId to signIn (courier.shared.signIn({ userId, jwt, tenantId })). It applies to both the component and the hooks. See How to generate a JWT for issuing tokens.
The userId you sign in with must match the to.user_id in your send requests, or preference enforcement won’t line up.

Prebuilt Component

<CourierPreferences> renders a complete preference interface (subscription topics, channel selection, digest schedules) with the SDK’s modern UI, native theming, and built-in dark mode.

Props

Theming is applied natively through props (no styled-components). The defaultPreferencesLightTheme, defaultPreferencesDarkTheme, and mergePreferencesTheme(mode, overrideTheme) utilities are exported for building on the defaults. Tenant scope is set on signIn, not per component.

Headless Hooks

For a fully custom UI, read and write preferences through useCourier().preferences:

Preference Methods

Tenant scope comes from signIn; these methods take no tenantId argument.

Which Approach

Not using React? Embed the <courier-preferences> web component in any framework, or manage preferences from your backend with the User Preferences API.