"use client"

import { useEffect } from "react"

/**
 * Registers the service worker on mount.
 * Must be rendered as a client component in the root layout.
 */
export function ServiceWorkerRegistration() {
  useEffect(() => {
    if ("serviceWorker" in navigator && process.env.NODE_ENV === "production") {
      navigator.serviceWorker.register("/sw.js").catch((err) => {
        console.warn("SW registration failed:", err)
      })
    }
  }, [])

  return null
}
