Skip to content

Latest commit

 

History

History

example

cf-webpush example

This is an example sveltekit project using cf-webpush hosted on Cloudflare Pages.

The usage here is pretty simple, the public key (required to subscribe to push notification) is sent through server load function (docs) and when user submitted the form, it's processed by the form action (docs) to send the notification.

You can generate your own JWK by running the code below in your browser console or Node.js REPL.

await crypto.subtle
	.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, ['sign', 'verify'])
	.then(({ privateKey }) => crypto.subtle.exportKey('jwk', privateKey));