T
TanStack4w ago
foreign-sapphire

Redirecting /admin/ to /admin/displays

Hi guys, quick question, but first a bit of context. I'm using admin.tsx as a layout route. admin.index.tsx is just a placeholder since the real entry point for /admin is admin.displays.tsx. I want to redirect /admin/ to /admin/display. Is it okay to just add a loader in admin.index.tsx for the redirect, or is there a cleaner way to handle this in TanStack Router?
export const Route = createFileRoute("/admin/")({
loader: () => {
throw redirect({ to: "/admin/displays" });
},
});
export const Route = createFileRoute("/admin/")({
loader: () => {
throw redirect({ to: "/admin/displays" });
},
});
As much as possible, I’d like to skip that extra step and land directly on /admin/displays without needing the admin.index.tsx route just for the redirect.
2 Replies
subsequent-cyan
subsequent-cyan4w ago
throw the redirect in beforeLoad there is no other way than redirecting
foreign-sapphire
foreign-sapphireOP4w ago
I see, thanks!

Did you find this page helpful?