17 lines
558 B
TypeScript
17 lines
558 B
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { useRouter } from "next/navigation";
|
|
|
|
// Client-side redirect: we deliberately don't use `redirect()` from
|
|
// next/navigation on the server, because that returns a 307 before the OG
|
|
// `<head>` is ever served. With `generateMetadata` + a 200 body, social-link
|
|
// scrapers get the full OG card while real users still get redirected.
|
|
export function RedirectClient({ to }: { to: string }) {
|
|
const router = useRouter();
|
|
useEffect(() => {
|
|
router.replace(to);
|
|
}, [router, to]);
|
|
return null;
|
|
}
|