Expert guide for implementing Progressive Web App (PWA) features within the Nexus Ecosystem, including install prompts, notifications, and offline capabilities.
Expert guide for implementing Progressive Web App (PWA) features within the Nexus Ecosystem, including install prompts, notifications, and offline capabilities.
PWA features must be implemented with a strict focus on SSR Safety, Type Integrity, and Standardized Overlay Behavior.
PWA components located in core/src/components/pwa/ (that are not registry-injected) MUST use named PascalCase exports. This distinguishes them from Registry components that use default exports.
export function ComponentName().'use client'; at the top of the file to ensure proper hydration.Components interacting with browser-only APIs (window, sessionStorage, matchMedia) must perform safety checks to prevent errors during server-side rendering (SSR) or build-time generation in Astro.
typeof window !== 'undefined' checks or executed within useEffect hooks.if (typeof window === 'undefined') return false;To maintain strict type safety while handling experimental browser events (like beforeinstallprompt), you MUST define local interfaces that extend the base Event type.
examples/before-install-event.ts.System-level prompts and overlays use specific Tailwind animation classes combined with fixed positioning to provide a consistent "operating system" feel.
animate-in and slide-in-from-* classes for entry transitions.bg-card, text-card-foreground) as defined in core/THEME.md and core/CODE.md.fixed bottom-4 md:right-4 z-50 animate-in slide-in-from-bottom-4 bg-card text-card-foregroundUser preferences for dismissing transient UI (like PWA banners) are persisted in sessionStorage to prevent intrusive behavior within a single session without requiring a database round-trip.
sessionStorage and validated during component mount.sessionStorage.setItem('pwa-banner-dismissed', 'true');Interactive elements and major containers must include data-testid attributes to facilitate robust end-to-end testing as mandated by the project's testing protocols.
data-testid attribute (e.g., data-testid="install-prompt").A reference implementation of the InstallPrompt component following all architectural mandates.
Demonstrates the typed interface extension for PWA-specific browser events.