Skip to content

fix: wrap login page in Suspense boundary#29

Merged
TerrifiedBug merged 1 commit intomainfrom
fix/login-suspense-boundary
Mar 7, 2026
Merged

fix: wrap login page in Suspense boundary#29
TerrifiedBug merged 1 commit intomainfrom
fix/login-suspense-boundary

Conversation

@TerrifiedBug
Copy link
Copy Markdown
Owner

Summary

Root cause

useSearchParams() without a Suspense boundary causes Next.js to bail out of static generation during next build, resulting in the prerender error on /login.

Test plan

  • pnpm build passes — /login prerendered as static content

PR #28 added useSearchParams() to the login page for SSO error
messages, but Next.js requires a Suspense boundary around components
using this hook or static prerendering fails during build.
@github-actions github-actions bot added the fix label Mar 7, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a Next.js static prerendering failure on /login caused by useSearchParams() being called at the top level of the page without a <Suspense> boundary. The fix is a single-file change that correctly extracts all page logic into an inner LoginPageContent component and wraps it in <Suspense>, allowing Next.js to statically prerender the outer shell while deferring the useSearchParams-dependent content to the client.

  • The LoginPage default export is now a pure Suspense shell — no hooks, no logic — which is exactly what Next.js requires to allow static optimization of the page route.
  • LoginPageContent is an internal, non-exported function component that contains all the existing logic untouched.
  • The fallback (a <Card> with a Loader2 spinner) is consistent with the existing checkingSetup loading state already rendered inside LoginPageContent.
  • No logic, security behaviour, or component structure was changed beyond the Suspense extraction.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-targeted fix with no logic changes that resolves a Next.js build issue.
  • The change is a textbook Suspense extraction pattern for Next.js useSearchParams(), affecting a single file. All existing logic is preserved verbatim inside LoginPageContent, and the outer LoginPage component introduces no new behaviour. No security-sensitive paths, auth flows, or data handling are altered.
  • No files require special attention.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[next build] --> B[LoginPage\ndefault export]
    B --> C[Suspense boundary\nfallback: Card + Loader2 spinner]
    C -->|Loading| D[Fallback spinner rendered]
    C -->|Resolved| E[LoginPageContent]
    E --> F[useSearchParams]
    E --> G[useRouter]
    F --> H{error param present?}
    H -->|Yes| I[setError with SSO_ERROR_MESSAGES\nreplaceState to clean URL]
    H -->|No| J[Normal login form render]
    E --> K{checkingSetup?}
    K -->|True| L[Inline spinner card]
    K -->|False| M[Full login / TOTP / SSO form]
Loading

Last reviewed commit: 6fdfefe

@TerrifiedBug TerrifiedBug merged commit d82893f into main Mar 7, 2026
12 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/login-suspense-boundary branch March 7, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant