NJ Municipality Lookup

Pwa

Progressive Web App (PWA) components for enabling installation and offline functionality.

PWA Components

Progressive Web App (PWA) components for enabling installation and offline functionality.

Components

ServiceWorkerRegistration

Client-side component that registers the service worker for PWA functionality.

File: service-worker-registration.tsx

Purpose: Registers /sw.js service worker in production to enable:

  • Offline static asset caching
  • PWA installation
  • Background updates

Usage: Automatically included in root layout (src/app/layout.tsx). No direct interaction needed.

Behavior:

  • Only registers in production (skipped in development to avoid HMR conflicts)
  • Checks for service worker updates
  • Logs registration status to console
  • Renders nothing (invisible component)
  • Service Worker: public/sw.js - Handles fetch events and caching
  • PWA Manifest: public/manifest.json - Defines app metadata
  • Documentation: docs/pwa-setup.md - Full PWA implementation guide

Future Components

Potential PWA components for future implementation:

  • InstallPrompt: Show custom PWA install prompt
  • UpdateNotification: Notify users when new version available
  • OfflineIndicator: Display connection status
  • BeforeInstallPrompt: Capture and defer install prompt

On this page