Difference between replace and redirect
Answered
Polish posted this in #help-forum
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 serverside2 Replies
@Polish What is the difference between
js
import { useRouter } from "next/navigation";
// ...
const { replace } = useRouter();
replace("/");
js
import { redirect } from "next/navigation";
// ...
redirect("/")
replace is for client side because it is returned from a hook and redirect is for serversideAnswer
PolishOP
thanks