fix: wrap useSearchParams pages in Suspense for prerender
Next.js 15 static prerender bails out when useSearchParams is used outside a Suspense boundary. Extract the hook-using component into an inner child and wrap it in Suspense at the page root. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { Suspense, useEffect, useRef } from 'react';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
|
||||
export default function PortalVerifyPage() {
|
||||
function PortalVerifyInner() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const calledRef = useRef(false);
|
||||
@@ -33,3 +33,17 @@ export default function PortalVerifyPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function PortalVerifyPage() {
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="min-h-screen flex items-center justify-center bg-gray-50">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-[#1e2844]" />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<PortalVerifyInner />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user