A React library for tracking Web Monetization state
npm install @interruptor/react-monetization- What is this?
- Installation
- Usage
- WebMonetizationProvider
- useWebMonetization
A React library for tracking Web Monetization state in your app.
``bash`
npm install @interruptor/react-monetization
First, you need to wrap your application with the WebMonetizationProvider. This sets up the event listeners needed for tracking web monetization events.
`jsx`
const MyApp = ({ children }) => {
return
}
The useWebMonetization hook provides information about the current Web Monetization state, whether it's "pending", "started" or "stopped". For convenience, there's also an isActive property, for knowing whether it's on or off.
`jsx
const MyComponent = () => {
const monetization = useWebMonetization()
if (monetization.isActive) {
return
Web Monetization is enabled! š
return
It's off
ā ļø _The hook will throw an error if used outside of the
WebMonetizationProvider`_