#
Add a public page
By default, when a route is registered with the registerRoute function, the route is considered as "protected". This doesn't imply that the route becomes inacessible to unauthenticated users thought; as this protection is typically granted by an authentication boundary. What it means is that if the AppRouter component's onLoadPublicData and onLoadProtectedData handlers are defined, both handlers will be executed when the route is requested (assuming it is the initial request).
Therefore, if a route and its layout do not rely on the initial protected data of the application, the route should be declared as public
using the $visibility
option:
import type { ModuleRegisterFunction, FireflyRuntime } from "@squide/firefly";
import { Page } from "./Page.tsx";
export const register: ModuleRegisterFunction<FireflyRuntime> = runtime => {
runtime.registerRoute({
$visibility: "public",
path: "/page",
element: <Page />
});
}
By doing so, only the onLoadPublicData
handler will be executed when the public route is requested (assuming it is the initial request).