Headless hooks
Build a fully custom Subscription interface using hooks.
Novu @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.
@novu/nextjs, @novu/react-native, @novu/react. For a complete reference on all available Subscription endpoints, refer to the API reference documentation.Get all subscriptions
The useSubscriptions 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 content they've opted into.
The subscriptions array contains TopicSubscription objects. You can refer to the TopicSubscription interface in the @novu/js package for the full type definition.
Get a single subscription
If you need to manage a specific subscription instance, then use the useSubscription hook. This hook fetches the details and preference states for a single subscription.
Create a subscription
To allow users to opt-in to a topic, use the useCreateSubscription hook. This is often used on "Follow" or "Subscribe" buttons.
Update a subscription
Use useUpdateSubscription 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 the useRemoveSubscription hook.