Documentation
Authenticated routes
Use wrapper routes to prepare auth state before rendering protected children.
For protected route trees, use a wrapper route that prepares authentication state once and controls how children render.
import { r } from '@plumile/router';
import {
AccountPageResource,
LoginPageResource,
ProtectedShellResource,
} from './common/resources.js';
import { prepareAuthStatus, prepareLoginPage } from './common/prepares.js';
import { renderAuthenticatedRoute } from './common/renders.js';
export const routes = [
r({
: '',
: ProtectedShellResource,
: prepareAuthStatus,
: renderAuthenticatedRoute,
: [
r({
: 'account',
: AccountPageResource,
}),
],
}),
r({
: 'login',
: LoginPageResource,
: prepareLoginPage,
}),
];Keep auth checks in the wrapper prepare/render pair. Child routes can focus on their own data and UI once the wrapper has established whether the user is allowed to see protected content.