From 58e6623ed39ff662bcce9b463c43b83376c7a80a Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 29 Nov 2025 19:56:29 -0800 Subject: [PATCH] fix: pass through server data in +layout.ts for Navigation props MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The universal load function (+layout.ts) was only returning { queryClient } without passing through the server data from +layout.server.ts. This caused Navigation component to not receive the account and currentUser props, resulting in the avatar and username not displaying even when authenticated. Root cause: - +layout.server.ts correctly returned account, currentUser, isAuthenticated - +layout.ts received this data but only returned queryClient - +layout.svelte tried to access data.account and data.currentUser but they were undefined because +layout.ts didn't pass them through Fix: - Added ...data spread to +layout.ts return statement to pass through all server data along with queryClient - Removed debug logging from Navigation.svelte and +layout.server.ts Result: - Navigation now correctly receives account and currentUser props - User avatar and username display properly when authenticated - isAuth derived from authStore remains reactive 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/routes/+layout.server.ts | 18 ------------------ src/routes/+layout.ts | 6 +++++- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 4ba0a5da..396a7a43 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -12,24 +12,6 @@ export const load: LayoutServerLoad = async ({ locals }) => { const currentUser = locals.session.user ?? null const isAuthenticated = locals.session.isAuthenticated - // Debug logging for auth data - if (locals.auth) { - console.log('[+layout.server] Auth data being passed to client:', { - hasToken: !!locals.auth.accessToken, - hasUser: !!locals.auth.user, - hasExpiresAt: !!locals.auth.expiresAt - }) - } - - // Debug logging for Navigation props - console.log('[+layout.server] Navigation props:', { - hasAccount: !!account, - account, - hasCurrentUser: !!currentUser, - currentUser, - isAuthenticated - }) - return { isAuthenticated, account, diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 80df6c7f..7c3a59fd 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -41,5 +41,9 @@ export const load: LayoutLoad = async ({ data }) => { } }) - return { queryClient } + // Pass through server data (account, currentUser, etc.) along with queryClient + return { + ...data, + queryClient + } }