Next.js Discord

Discord Forum

Is my approach the most optimal ?

Unanswered
Red-necked Grebe posted this in #help-forum
Open in Discord
Red-necked GrebeOP
So, I have a route called "category" , and a sub-route as a slug called [categoryID] , I want when the user visits /category to be redirected into /category/1 , and my approach to do so was simply creating a page.tsx inside /category, and returning a redirect() function to category/1 , is this the most optiomal approach ? is there a more standard one ?

// /category/page.tsx
import { redirect } from "next/navigation";

type Props = {};

function page({}: Props) {
return redirect("/category/1");
}

export default page;

2 Replies