Overview
ClipSync is built as a Progressive Web App (PWA), which means it can work partially offline and be installed on your device like a native app. The service worker caches resources for offline access and syncs when you reconnect.PWA Configuration
ClipSync uses Vite’s PWA plugin to configure the Progressive Web App capabilities.Service Worker Setup
From vite.config.js:9-14:vite.config.js:9-14
The
autoUpdate registration type ensures the service worker automatically updates when new versions are deployed.App Manifest
The PWA manifest defines how ClipSync appears when installed:vite.config.js:18-49
Manifest Properties
- Display mode:
standalone- Appears as a full-screen app without browser UI - Icons: Three sizes (96x96, 192x192, 512x512) for different devices
- Theme: Black theme color for consistency with the app design
- Orientation: Portrait mode preferred
Online/Offline Detection
ClipSync actively monitors your connection status and adapts functionality accordingly.Connection State Management
src/App.jsx:27
Event Listeners
From App.jsx:40-53:src/App.jsx:40-53
Automatic Sync on Reconnection
When you come back online, ClipSync automatically:- Updates the offline status
- Fetches the latest clipboard history after a 100ms delay
- Resumes realtime subscriptions
Offline Indicator
A prominent banner appears when offline:src/App.jsx:474-477
What Works Offline vs Online
Works Offline
View UI
Browse the app interface and navigation
Read History
View previously synced clipboard entries
Type Content
Draft content in the textarea (stored in sessionStorage)
Search History
Filter through cached clipboard history
Requires Online Connection
Send Content
Upload new clipboard entries to the database
Real-time Sync
Receive updates from other devices
File Upload
Upload files to Supabase Storage
Join Session
Connect to or create new sessions
Delete Items
Remove clipboard entries from the database
Service Worker Caching
The service worker caches all app resources for offline access:Cache Strategy
vite.config.js:12-16
- HTML files
- JavaScript bundles
- CSS stylesheets
- Images and icons
- Fonts
The
**/* glob pattern ensures all assets are cached for offline availability.Realtime Subscription Behavior
The realtime subscription automatically pauses when offline:src/App.jsx:410
isOffline as a dependency, meaning:
- When offline, the connection is cleaned up
- When back online, a new subscription is established
- No wasted resources trying to maintain connections while offline
SessionStorage for Draft Content
ClipSync uses sessionStorage to preserve your draft content even if the page refreshes:src/App.jsx:523-527
src/App.jsx:15
Installing as PWA
ClipSync can be installed on your device:- Open ClipSync in a supported browser (Chrome, Edge, Safari, Firefox)
- Look for the “Install” or “Add to Home Screen” prompt
- Click install to add ClipSync to your device
- Launch from your home screen or app drawer
Benefits of Installation
- Faster loading: Cached resources load instantly
- App-like experience: Full-screen without browser chrome
- Desktop icon: Quick access from home screen/desktop
- Better offline support: More aggressive caching when installed
Network State in Supabase
Supabase client operations gracefully handle offline scenarios:- Queued requests: Some operations may queue and retry when online
- Error handling: Database operations fail with clear error messages when offline
- Automatic reconnection: Realtime subscriptions automatically reconnect
While offline, operations that require the database will fail with error messages. These will succeed once you reconnect.