fix(dashboard): show skeleton instead of default layout until hydration completes

Root cause: useDashboardLayout initialised React state with createDefaultDashboardLayout()
(1 widget), so the wrong default rendered during the ~100–500ms window while React Query
fetched the user session and DB layout after login. On reload within staleTime the cache
hit resolved instantly, masking the bug.

Fix: add isHydrated boolean state that becomes true only once localStorage OR DB
hydration has settled; DashboardClient renders a GridLayoutSkeleton until then.
Also adds router.refresh() in the sign-in handler to bust the Next.js Router Cache
so the post-login navigation always lands on a fresh server component tree.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-09 10:20:50 +02:00
parent 24435a1824
commit a16c41e739
3 changed files with 69 additions and 10 deletions
+3
View File
@@ -59,6 +59,9 @@ export default function SignInPage() {
setTotp("");
}
} else {
// Invalidate the Next.js Router Cache so (app)/layout.tsx re-renders
// with the fresh session, then navigate to the dashboard.
router.refresh();
router.push("/dashboard");
}