Creating a custom route based on createFileRoute? #2865
-
Hello, I'm trying to create a custom route called export const createProtectedRoute = (
path: keyof FileRoutesByPath,
Component: RouteComponent,
// :: additional args
) => {
return createFileRoute(path)({
component: Component,
beforeLoad: ({ location }) => {
const auth = useAuthStore.getState();
if (!auth.accessToken) {
throw redirect({
to: "/login",
search: {
redirect: location.href,
},
});
}
},
// :: Add more args here
});
};
// :: Sample implementation
export const Route = createProtectedRoute("/", HomeComponent); While this works, I'd like to make it more flexible by adding support for additional arguments like |
Beta Was this translation helpful? Give feedback.
Answered by
schiller-manuel
Nov 26, 2024
Replies: 1 comment
-
this won't work well with automatic codesplitting unfortunately. we have this in our backlog but not planned yet. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ThanMatt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this won't work well with automatic codesplitting unfortunately. we have this in our backlog but not planned yet.