Skip to main content

Overview

Embed Courier’s preference management directly into your application 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 a completely custom interface. Either way, preferences feel native to your app and stay in 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. They expose the same API.

Authentication

Preferences authenticate with a JWT, not a client key. Generate the token server-side and include 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 have already signed in for Inbox or Toast, no additional sign-in is needed.
To scope preferences to a tenant, pass tenantId to signIn (courier.shared.signIn({ userId, jwt, tenantId })). It applies to both the component and the headless hooks. See How to generate a JWT for issuing tokens.
Critical: The userId you sign in with must match the to.user_id used in your send requests, or preference enforcement will not 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). Theme utilities defaultPreferencesLightTheme, defaultPreferencesDarkTheme, and mergePreferencesTheme(mode, overrideTheme) 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

For non-React or server-side integrations, use the User Preferences API (REST) directly.

Next Steps

Preferences Editor

Configure subscription topics, sections, and digest schedules

Hosted Preference Center

Compare with the turnkey hosted option

React v8+ Migration Guide

Full component, theming, and hook reference

User Preferences API

Manage preferences programmatically over REST