Help with routing and automatic redirection to a child page when landing to parent page
Answered
Sun bear posted this in #help-forum
Sun bearOP
As shown in the attachment, I have a relatively simple architecture in which I try to render tabs dynamically with Next. That said, since I only have a layout for rate-evolution (which isn't supposed to host a page, it's just a "category") I'd like to automatically redirect the user to rate-evolution/tv when he arrives at rate-evolution.
In general, if anyone has any advice on how to handle tabs in material ui X nextjs, I'd love to hear from you.
Thanks !
In general, if anyone has any advice on how to handle tabs in material ui X nextjs, I'd love to hear from you.
Thanks !
Answered by joulev
// rate-evolution/page.tsx
import { redirect } from "next/navigation";
export default function Page() {
redirect("/rate-evolution/tv");
}5 Replies
@Sun bear As shown in the attachment, I have a relatively simple architecture in which I try to render tabs dynamically with Next. That said, since I only have a layout for rate-evolution (which isn't supposed to host a page, it's just a "category") I'd like to automatically redirect the user to rate-evolution/tv when he arrives at rate-evolution.
In general, if anyone has any advice on how to handle tabs in material ui X nextjs, I'd love to hear from you.
Thanks !
// rate-evolution/page.tsx
import { redirect } from "next/navigation";
export default function Page() {
redirect("/rate-evolution/tv");
}Answer
Sun bearOP
Simple as that ? lmao
Is there a better way to manage this or is this ok ?
you have many ways to perform a redirect in nextjs. https://nextjs.org/docs/app/building-your-application/routing/redirecting. the 5 liners above is one of those ways.
Sun bearOP
Thanks very much !