Redirecting
Answered
Shaurya posted this in #help-forum
ShauryaOP
what is the best way to create redirect routes? like when I go to
I could make a component like
is this the way or is there any better way to do the same?
/social/discord it recirects me to the link I've setI could make a component like
import { useEffect } from "react"
import { useRouter } from "next/router"
export default function RedirectPage({ link }: Props) {
const router = useRouter()
useEffect(() => {
router.replace(link)
}, [])
return null
}and reuse this component in every redirect route, so for /social/discord export default <RedirectPage link={myDiscordLink} />is this the way or is there any better way to do the same?
Answered by averydelusionalperson
3 Replies
ShauryaOP
anyone please help me out with this
you can just use
redirect function