Add a 'noAccessComponent' to the Root Route #1206
QVladislav
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As there are already components as 'notFoundComponent' and 'errorComponent', it should be nice to have a component that manages access on pages.
I know there is a solution to add authentication for routes, but I think it's more streamlined to use a general component for it.
When I make the code like this:
export const Route = createFileRoute('/knowledgebase/profiles')({ component: () => { const { user } = useAuth() if (user?.email_verified) { return <NoAccessPage /> } }, })
The NoAccessPage will be displayed in my RootLayout instead of the whole page.
Beta Was this translation helpful? Give feedback.
All reactions