@vaadin/hilla-file-router
Version:
Hilla file-based router
21 lines • 707 B
JavaScript
import { protectRoute } from "@vaadin/hilla-react-auth";
/**
* Creates a route transformer that applies route protection to a given route,
* optionally redirecting unauthorized access to a specified path.
*
* @param redirectPath - Optional path to redirect unauthorized users to.
* Defaults to '/login'.
*
* @returns A route transformer function that applies protection to the route.
*/
export default function createProtectTransformer(redirectPath) {
return ({ original, children }) => {
if (!original) {
return original;
}
const finalRoute = protectRoute(original, redirectPath);
finalRoute.children = children;
return finalRoute;
};
}
//# sourceMappingURL=./createProtectTransformer.js.map