DEV Community

Cover image for react-monetize submition 💸
Guido Vizoso
Guido Vizoso

Posted on • Updated on

react-monetize submition 💸

What I built

react-monetize is a set of helpers and hook to easily integrate the Web Monetization API with React.

Submission Category: Foundational Technology


Demo and code can be found on the documentation website:

Link to Code

GitHub logo guidovizoso / react-monetize

Helpers and hooks to speed up your integration with Web Monetization API



Helpers and hooks to speed up your integration with Web Monetization API

Version CI License: MIT npm Twitter: guido\_vizoso


Currently supports React, Create React App and Next Js Not yet tested in Gatsby or Preact.

yarn add react-monetize


Wrap your app with the MonetizeProvider and add your payment pointer.

You can read how to get one here:

import { MonetizeProvider } from 'react-monetize';
function App() {
    return (
        <MonetizePovider paymentPointer="myPaymentPointer">
            <YourApp />
export default App;

Now you have two hooks available to use anywhere in your app:


State is the current state provided by Web Monetization API according to this list.

Events are the payment events registered stored as CustomEvent.

import { useStatus } from 'react-monetize';
function Component() {
    const { state, events } = useStatus()

How I built it

First thing I did was heading to and read the documentation.
With that knowledge in mind I prepared the layout for creating the components.
The goal was to make it as React as possible so people could use the benefits of the Web Monetization API without having to worry about integration. Just wrap your App, add your payment pointer and you're good to go.
Once you prepared your App you'll have access to useStatusand useContent to build with the API.

react-monetize uses these technologies:

  • Typescript.
  • Rollup for the bundling.
  • React (obviusly).
  • React Testing Library & Jest for testing.
  • ESLint & Prettier to ensure code quality.

Additional Resources/Info

Hope you liked the project and feel free to comment, make a PR, fork it or use it in your own idea!
Stay safe and have a great week!

Top comments (2)

dfoderick profile image
Dave Foderick

Thanks Guido. I am enjoying your library.

guidovizoso profile image
Guido Vizoso

Glad you like it and thanks again for spotting that issue!