Server Side Rendering (SSR)

Load authenticated user and organization data on the server instead of waiting for the client to fetch it. This improves performance and eliminates the flash of an unauthenticated state.

Why it matters

  • Pages render with user context immediately (no flash of “logged-out” state).
  • Reduces client-side fetches and speeds up perceived performance.

Enable SSR for User Management

Fetch the active user and connected accounts in your root layout.

src/routes/+layout.server.ts

Pass this data into your layout:

src/routes/+layout.svelte

Enable SSR for Organizations

Extend the same approach to preload organization data.

src/routes/+layout.server.ts

Update the layout to pass preloaded org data into the OrganizationSwitcher:

src/routes/+layout.svelte

Summary

With SSR enabled:

  • UserButton renders instantly with the logged-in user’s account data.
  • OrganizationSwitcher is populated on first paint.
  • You avoid loading spinners or empty states on every navigation.
  • Authenticated pages benefit from faster load and better UX.