redirect-workaround.tsx (1222B)
1 "use client"; 2 import { useEffect } from "react"; 3 import { useRouter } from "next/navigation"; 4 export default function RedirectionPageClient({ redirectUrl, replace }: { redirectUrl: string; replace?: boolean }) { 5 const router = useRouter(); 6 useEffect(() => { 7 if (replace) { 8 router.replace(redirectUrl); 9 } else { 10 router.push(redirectUrl); 11 } 12 }, [redirectUrl, replace, router]); 13 return ( 14 <div className="flex h-full w-full min-h-screen min-w-screen flex-col bg-black text-white items-center justify-center"> 15 <h1 className="text-2xl font-bold">Redirecting...</h1> 16 <p className="mt-4">If you are not redirected automatically, please click the button below.</p> 17 <button 18 className="mt-4 px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600" 19 onClick={() => { 20 if (replace) { 21 router.replace(redirectUrl); 22 } 23 else { 24 router.push(redirectUrl); 25 } 26 }} 27 > 28 Go to {redirectUrl} 29 </button> 30 </div> 31 ) 32 }