Docs Surfacing Mantle data useMantle() hook

useMantle() hook

The useMantle() hook allows you to access properties and actions which are surfaced by the MantleProvider’s context, and can be accessed by calling useMantle() from within a functional React component, like so:

const {
  subscription,       // the active subscription, if any
  plans,              // list of plans available for this customer
  customer,           // any details about the customer
  loading,            // whether the mantle api is loading
  subscribe,          // initiate the subscription flow
  cancelSubscription, // cancel the active subscription
  pushEvent,          // send a usage event for the active subscription
  isFeatureEnabled,   // check if the active subscription has a feature
  refetch,            // refetch all data from the mantle api
} = useMantle();

Check out the @heymantle/surface project to learn more.