I want to redirect users in NextJS similar to how you can use useNavigate()
. <Link />
is not good enough for this, because I want the user to be immediately redirected.
I suppose you would be looking for the useRouter
hook to access the router
object and issue an imperative navigation action.
Example:
const router = useRouter();
...
router.replace(targetInAppUrl);
See router.push or router.replace for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With