Next.js Discord

Discord Forum

Difference between replace and redirect

Answered
Polish posted this in #help-forum
Open in Discord
PolishOP
What is the difference between
import { useRouter } from "next/navigation";
// ...
const { replace } = useRouter();
replace("/");

import { redirect } from "next/navigation";
// ...
redirect("/")
Answered by @ts-ignore
replace is for client side because it is returned from a hook and redirect is for serverside
View full answer

2 Replies

Answer
PolishOP
thanks