Skip to content

feat: implement PWA offline support with pending transaction queue - #640

Open
Davichi-1 wants to merge 7 commits into
Stellar-split:mainfrom
Davichi-1:feat/issue-385-implement-pwa-offline-support-with-service
Open

feat: implement PWA offline support with pending transaction queue#640
Davichi-1 wants to merge 7 commits into
Stellar-split:mainfrom
Davichi-1:feat/issue-385-implement-pwa-offline-support-with-service

Conversation

@Davichi-1

Copy link
Copy Markdown

Overview

This PR adds full PWA offline support to split-app with service worker caching and an IndexedDB-backed pending transaction queue. Invoice reads from the last session are served from cache when offline. Pending pay/approve transactions submitted while offline are queued in IndexedDB and auto-submitted when connectivity is restored. An offline banner communicates queue status, and the manifest uses correct StellarSplit branding.

Related Issue

Closes #

Changes

📱 PWA & Service Worker

  • [MODIFY] next.config.js

    • Configure next-pwa for service worker generation.
    • Cache strategy: network-first for API routes, cache-first for static assets.
  • [ADD] public/sw.js

    • Runtime caching for the app shell, static assets, and API responses.
    • Offline fallback for invoice data from the last session.
  • [MODIFY] public/manifest.json

    • StellarSplit branding: name, icons, start_url, display standalone, and theme color #0B1628.
  • [MODIFY] src/app/layout.tsx

    • Add manifest link and theme-color metadata for PWA installability on mobile and desktop.
  • [MODIFY] package.json

    • Add next-pwa, idb, and test-related dependencies/scripts.

🔌 Offline Queue & IndexedDB

  • [ADD] src/lib/offlineQueue.ts

    • IndexedDB-backed pending transaction queue using idb.
    • When a pay/approve transaction fails due to a network error, store it in the queue.
    • On reconnect, drain the queue automatically with retry logic; remove items only after successful submission.
  • [ADD] src/components/OfflineQueueSync.tsx

    • Listens for online/offline events and triggers queue drain.
    • Shows the offline banner: "You're offline — pending transactions will submit when you reconnect".

🧪 Tests

  • [ADD] src/lib/__tests__/offlineQueue.test.ts
    • Unit tests for queue drain logic: ordering, retry on failure, clearing only successful transactions, and reconnect-triggered draining.

Verification Results

npm run lint
✅ 0 errors

npx tsc --noEmit
✅ 0 errors

npm run build
✅ Build succeeded

npm test -- src/lib/__tests__/offlineQueue.test.ts
✅ 8/8 passed

Manual PWA checks:
✅ Installable on mobile/desktop via manifest + service worker
✅ Invoice data visible offline from cache
✅ Pending transaction queued offline and auto-submitted on reconnect
✅ Offline banner rendered correctly
Acceptance Criteria Status
App installs as PWA on mobile and desktop ✅ Manifest + service worker registered; installable build verified
Invoice data visible offline from cache ✅ Network-first API with cache-first static assets; last session invoice data cached
Pending transactions queue and auto-submit on reconnect ✅ IndexedDB queue drains on online event with retry logic
Offline banner shown correctly OfflineQueueSync renders banner on connection loss
manifest.json has correct StellarSplit branding ✅ Name, icons, standalone display, theme #0B1628
npm run lint passes with zero errors ✅ 0 errors
TypeScript compiles with zero errors ✅ 0 errors
npm run build succeeds ✅ Build succeeded

Closes #385

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Davichi-1 is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement PWA offline support with service worker caching and IndexedDB pending transaction queue

1 participant