@novu/react package provides Subscription hooks that let you build your own custom subscription experiences from scratch.
These hooks allow you to list, create, update, and delete subscriptions while leveraging Novu’s state management.
Hooks are available in
@novu/nextjs, @novu/react-native, @novu/react. For a complete reference on all available Subscription endpoints, refer to the API reference documentation.List all subscriptions
TheuseSubscriptions hook retrieves all subscriptions associated with a specific topic for the current subscriber. This is useful for rendering a list of “My Subscriptions,” where subscribers can view all the subscriptions they’ve subscribed to.
The subscriptions array contains TopicSubscription objects. You can refer to the TopicSubscription interface for the full type definition.
Retrieve a single subscription
If you need to manage a specific subscription instance, then use theuseSubscription hook. This hook fetches the details and preferences for a single subscription.
Create a subscription
To allow users to opt-in to a topic, use theuseCreateSubscription hook. This is often used on “Follow” or “Subscribe” buttons.
Update a subscription
UseuseUpdateSubscription to modify an existing subscription. This is primarily used to toggle workflow preferences, enabling, or disabling specific notifications within the subscription.
Update a single preference
If you need to update a single preference, use the dedicated helpers available on the subscription object, such as:subscription.updatePreference(...), or- mapping over
subscription.preferencesand callingpreference.update(...)
Delete a subscription
To allow users to opt out or unsubscribe, use theuseRemoveSubscription hook.