Redirect doesn't redirect
Answered
Gecco posted this in #help-forum
GeccoOP
Hi. I have a select tag and
onChange={({ target }) => redirect(/?poem=${target.value})} attached to it which doesnt redirect me when clicked.Answered by West African Lion
redirect() is for server, useRouter() is for clientimport { useRouter } from 'next/router'
const router = useRouter();
onChange=(() => router.pushState('{YOUR_URL}'));4 Replies
West African Lion
redirect() is for server, useRouter() is for clientimport { useRouter } from 'next/router'
const router = useRouter();
onChange=(() => router.pushState('{YOUR_URL}'));Answer
West African Lion
redirect() returns an http response with a redirect status code along with a Location header, useRouter will use JS on the client side