Overview
Embed Courier’s preference management directly into your application using React components, custom hooks, or web components. This approach provides seamless user experience where notification preferences feel native to your application, with complete control over styling, layout, and user workflow integration. Embedded preferences maintain the full functionality of hosted preference centers while allowing deep customization to match your design system and user experience patterns.Example Implementation: View the complete Newsletter Preferences example to see embedded preferences in action.
Key Features
Embedded preference components provide comprehensive preference management with complete customization control:- Seamless Integration - Preferences feel native to your application without external redirects
- Complete Customization - Full control over styling, layout, and user experience design
- Multi-Framework Support - React components, custom hooks, and framework-agnostic web components
- Real-Time Updates - Immediate preference synchronization with Courier’s preference system
Core Components
React Components
PreferencesV4 Component
Pre-built React component that renders a complete preference interface with subscription topics, channel selection, and real-time updates.tenantId(optional): Specify tenant for multi-tenant applicationsdraft(optional): Show draft preferences before publishing
Custom React Hooks
Build completely custom preference interfaces using Courier’s preference hooks for maximum flexibility:recipientPreferences- Array of user preference objects with templateId and statuspreferencePage- Preference page configuration with sections and topicsfetchRecipientPreferences(tenantId)- Function to load user preferencesfetchPreferencePage(tenantId)- Function to load preference page structureupdateRecipientPreferences(config)- Function to update user preferencesisLoading- Boolean indicating if any requests are in progress
The
usePreferences hook handles API calls to the User Preferences API internally, providing a React-friendly interface for preference management.Explore Components: Use this interactive demo to explore Courier’s preference components and their capabilities.
Web Components
For non-React applications, use Courier’s web components that work with any JavaScript framework or vanilla HTML:Implementation Comparison
| Approach | Best For | Customization | Development Effort |
|---|---|---|---|
| PreferencesV4 | Quick integration, standard UI | Styling only | Minimal |
| Custom Hooks | Complex workflows, custom UX | Complete control | High |
| Web Components | Non-React apps, simple integration | CSS variables | Low |
Getting Started
Installation
@trycourier/react-preferences- Pre-built PreferencesV4 component@trycourier/react-hooks- Custom hooks like usePreferences for building custom UIs@trycourier/react-provider- CourierProvider for authentication and context
All @trycourier packages must use the same version for compatibility.
Authentication Setup
Get your Client Key from Channels > Courier in your Courier dashboard. Store it securely:User ID Requirements
Critical: The
userId in your preference components must match the to.user_id used in send requests for preference enforcement to work correctly.- Preference component initialization
- Send API requests
- User profile management
- Authentication systems
Next Steps
Preferences Editor
Configure subscription topics and sections for your embedded components
Hosted Preference Center
Compare with turnkey hosted preference center solution
User Preferences API
Programmatically manage user preferences and access custom routing data
React SDK Documentation
Explore additional React components and integration patterns