Few weeks back I started learning about building desktop applications using Electron. I was recently working on a mini project and was looking for some inspirations from the existing apps built using Electron. While searching for examples I came across few posts and discussions about monetizing Electron App. I thought it would be an another amazing opportunity to experiment with both Elecron and Web Monetization.
I worked on a small project which enables web monetization in electron
app. This is a very basic example of setting up web monetization in your electron app.
How I built it
I started with a basic electron app setup using the official documentation. This helped me to set up a simple starter electron app.
Now the next step was to load the Coil chrome extension in the main process after initializing the BrowserWindow.
To load the chrome extension you need to do the following:
Install the Coil exetsnion in your chrome browser this will help you to locate in your filepath system which you can refer later. ( A important step for setting up web monetization in your app)
Find the filepath location used by chrome for storing extensions.
Load the extension in your Main process.
Refer the link for more information about loading the extension in your app.
This will successfully register the coil extension in your BrowserWindow.
I have created one renderer process to demonstrate the use of web monetization. You can have multiple renderer process when you have multiple window objects.(Refer the link for learning more about the Processes.)
Once the extension is installed in the main process I inform the renderer process to add the monetization meta tag to the web page.
I have added meta tag in a renderer process as it defines a separate web page which has it's own process. If you wish to add it in all your renderer processes you can define it in the main process as well.
I have started with a very minimilistic project setup 😊
I am currently working to cover more aspects of web monetization that can be used in electron apps. This will make it easy for all the developers who want to monetize their Electron Apps with a quick setup and build amazing apps like Wordpress, slack etc 💵