The Interledger Community 🌱

Discussion on: Qwyre.com - A guide for integrating Coil & Web Monetization APIs for creatives doing the job once

Collapse
 
radhyr profile image
Radhy

There's so much information here Gavit. Nicely done 👍👍👍

Doing that in a Node app, though, will instantly crash your app during transitions since this is exactly the sort of state that Node will preserve. That means initialising the coilMonetizationPolyfill needs to look like this on every page:

This seems classic problems for frameworks that combine client-side hydration and server-side rendering, like Nuxt, Next, Sapper/SvelteKit. They run the code twice both in backend and frontend and since backend doesn't have document object thus the crash - which is why the solution is skipping the server-side by checking if process.client is truthy. I think traditional Node app that uses SSR without client-side rehydration (or detaching client-side framework from the server-side code) should be fine.