DEV Community

Jasmin Virdi
Jasmin Virdi

Posted on • Updated on

Web Monetization in Vue App using plugin

In this article I will be explaining how we can use plugins in Vue to extend the Web Monetization functionality to our Vue App.

Plugins are the most simple and easy way to add global features to our app. They can be used to extend additional capabilities like routing, immutable stores, analytics and DOM manipulations.

So let's try implementing Web Monetization using plugins in your Vue App.


  • Create a Web Monetization plugin.
// file: web-monetization.js

export default {
  install(Vue) {
    Vue.proptype.$webMonetizaton = this;
    Vue.webMonetizaton = this;

    if (typeof window !== "undefined") {
      window.$webMonetizaton = this;
  enableWebMonetization() {
    if (!document.monetized) {
      const monetizationTag = document.createElement("meta"); = "monetization";
      monetizationTag.content = "payment_pointer";

  disableWebMonetization() {
    const removeMonetizationTag = document.querySelector(

  webMonetizationEvents() {
    document.monetization.addEventListener("monetizationstart", currentState);

  currentState(event) {
Enter fullscreen mode Exit fullscreen mode
  • Register your plugin with your Vue App.
import Vue from "vue";
import { WebMonetizationPlugin } from "./web-monetization.js";

Enter fullscreen mode Exit fullscreen mode
  • Use plugin in your app.
//to enable web monetization

// to disable web monetization
Enter fullscreen mode Exit fullscreen mode

Link to code

You can find the code here


Web Monetization Doc
Vue js Plugins

Top comments (2)

detzam profile image

Soo, what does this webmonetizstion do, actually?

jasmin profile image
Jasmin Virdi

Web Monetization is a javascript browser API which support payments.
Here is the documentation link for more info 😄