How to fix: Next.js 16 App Router PWA + Supabase SSR: infinite loading on mobile/PWA (manual service worker likely caching RSC/Flight)

This Supabase/Next.js failure usually means the service worker is caching App Router or authenticated responses that must stay network-only. Limit caching to immutable static assets, purge old caches on activation, then retest login, refresh, and the installed PWA.

This pattern is common in AI-built Next.js and Supabase apps because generated code often leaves auth, cookie, deployment, or type boundaries unfinished. The exact symptom matters, so preserve the original error before changing code.

Why it happens

The service worker is likely caching App Router flight/RSC or authenticated responses that must stay network-only.

What to check

Check whether requests with `RSC`, `Next-Router-State-Tree`, or `accept: text/x-component` ever hit a cache.

Confirm `/api/*`, Supabase REST/Auth, navigation redirects, and auth-bound pages are network-only.

Compare the installed PWA cache keys before and after a deploy to find stale App Router payloads.

Test mobile with the service worker unregistered to prove whether the issue disappears.

Fix plan

Cache only immutable `/_next/static/*` assets and selected public images/icons.

Treat App Router internals, API routes, Supabase calls, and navigation requests as network-only with offline fallback only on network failure.

Bump cache version and delete all old Workbox/manual caches during activation.

Add a mobile/PWA smoke: login, refresh, close/reopen installed app, and verify dashboard state.

When to stop guessing

If this touches auth, RLS, database writes, storage, redirects, or deployment callbacks, a build-only fix is not enough. Verify the real user path against the same Supabase project and domain that failed.

Need a second set of eyes? Paste the exact error into the free diagnosis form and get a focused rescue plan before you spend more time guessing.