"use client";

import { useEffect } from "react";

export function PwaRegister() {
  useEffect(() => {
    if (!("serviceWorker" in navigator)) {
      return;
    }

    const registerWorker = async () => {
      try {
        await navigator.serviceWorker.register("/sw.js", {
          scope: "/"
        });
      } catch {
        // Silent fail in development environments where service workers are disabled.
      }
    };

    void registerWorker();
  }, []);

  return null;
}
