layout.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, { Suspense } from "react";
  2. import { Loader2 } from "lucide-react";
  3. import AppShell from "@/components/app-shell/AppShell";
  4. import AuthProvider from "@/components/auth/AuthProvider";
  5. /**
  6. * Protected layout (RHL-020)
  7. *
  8. * Best practice for `useSearchParams()`:
  9. * - AuthProvider uses `useSearchParams()` (client hook).
  10. * - During production builds, static prerendering requires a Suspense boundary
  11. * above the component using `useSearchParams()`.
  12. *
  13. * This Suspense fallback will be part of the initial HTML for static rendering.
  14. * After hydration, AuthProvider takes over and performs the session check.
  15. */
  16. function AuthProviderFallback() {
  17. return (
  18. <div className="min-h-screen w-full px-4">
  19. <div className="mx-auto flex min-h-screen max-w-md items-center justify-center">
  20. <div className="flex items-center gap-3 text-sm text-muted-foreground">
  21. <Loader2 className="h-4 w-4 animate-spin" />
  22. <span>Sitzung wird vorbereitet…</span>
  23. </div>
  24. </div>
  25. </div>
  26. );
  27. }
  28. export default function ProtectedLayout({ children }) {
  29. return (
  30. <Suspense fallback={<AuthProviderFallback />}>
  31. <AuthProvider>
  32. <AppShell>{children}</AppShell>
  33. </AuthProvider>
  34. </Suspense>
  35. );
  36. }