Wants to send user to NotFound Page
Answered
Caya posted this in #help-forum
CayaOP
so i have a fucntion which check if user exist or not if user exist it will send to next page else it will send to a 404 page idk how to do it i went through google and found that we can do this by using NotFound fucntion from next/navigation but its throwing a runtime err
Answered by @ts-ignore
if(userExist){
router.push(`/${username}`);
} else router.push("/this-route-does-not-exists")11 Replies
CayaOP
i am looking for a way to handle this if you have any better optiion i would love too
you cannot call
notFound() on client@@ts-ignore you cannot call `notFound()` on client
CayaOP
so can i use "use server" in that function
mb
@@ts-ignore you cannot call `notFound()` on client
CayaOP
what else i can do
you can send users to any page which doesn't exist which will show 404 page
@@ts-ignore you can send users to any page which doesn't exist which will show 404 page
CayaOP
eee i have a problem with that too.... hehe wait let me show you the snipint
if (userExist) {
router.push(`/${userName}`);
} else {
notFound();
}i guess i have to change my route
if(userExist){
router.push(`/${username}`);
} else router.push("/this-route-does-not-exists")Answer