This demonstration showcases the use of Cloudflare Workers to deliver push notifications through the Web Push API. When you click subscribe, your browser generates subscription credentials, which are then sent to a Cloudflare Worker and stored in a Workers KV database. The worker then returns a 6-character key, used to identify your subscription. As this is only a demo, these keys are retained for 24 hours and then deleted. You can then enter that same key on this page (even from another device), which will cause the worker to retrieve the subscription credentials and dispatch a notification, or bonk, to your browser.
On desktop Chrome and Firefox, notifications are only received when the browser is running. To use web push notifications on iOS or iPadOS, you will need to be in Safari and have this page saved to your home screen in order for the notification permission to succeed.
Demo by kyleplo. Source code available on Github.
Subscribe to get a key to get bonked.
Enter a key to bonk: