aboutsummaryrefslogtreecommitdiff
path: root/static/service-worker/index.js
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-11-23 16:41:43 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2025-11-23 16:41:43 +0100
commit1e31b71afd1ead4644e99df6838a55481176e09a (patch)
treef1107a55f2b2f6ed838190ac259cd5b698bcc56f /static/service-worker/index.js
parent2e8f59aaeb731dd726f8d49d120ae4cc8a7cf512 (diff)
add fonts and create-user endpoint
Diffstat (limited to 'static/service-worker/index.js')
-rw-r--r--static/service-worker/index.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/static/service-worker/index.js b/static/service-worker/index.js
new file mode 100644
index 0000000..cff4b95
--- /dev/null
+++ b/static/service-worker/index.js
@@ -0,0 +1,21 @@
+export const register = async () => {
+ if (!'serviceWorker' in navigator) {
+ console.warn('service worker not supported by browser');
+ return;
+ }
+
+ try {
+ const registration = await navigator.serviceWorker.register("/service-worker/worker.js", {
+ scope: "/",
+ });
+ if (registration.installing) {
+ console.log("Service worker installing");
+ } else if (registration.waiting) {
+ console.log("Service worker installed");
+ } else if (registration.active) {
+ console.log("Service worker active");
+ }
+ } catch (error) {
+ console.error(`Registration failed with ${error}`);
+ }
+}