💸
react-monetize
Helpers and hooks to speed up your integration with Web Monetization API
Install
Currently supports React, Create React App and Next.Js Not yet testd in Gatsby or Preact.
yarn add react-monetize
Usage
Wrap your app with the MonetizeProvider
and add your payment pointer.
You can read how to get one here: https://webmonetization.org/docs/receiving
import { MonetizeProvider } from 'react-monetize'
function App() {
return (
<MonetizePovider paymentPointer="myPaymentPointer">
<YourApp />
</MonetizeProvider>
)
}
export default App;
Now you have two hooks available to use anywhere in your app:
useStatus
State is the current state provided by Web Monetization API according to this list.
import { useStatus } from 'react-monetize'
function Component() {
const { state, events } = useStatus();
return (
<>
<p>State: {state}
…