Replies: 1 comment 3 replies
-
maybe there's a cleaner way, but you can just fetch the user's auth and then conditionally render the navbar in the root component const Nav = () => {
return (
<div className="p-2 flex gap-2">
<Link to="/" className="[&.active]:font-bold">
Home
</Link>{" "}
<Link to="/about" className="[&.active]:font-bold">
About
</Link>
<Button>
Logout
</Button>
</div>
);
};
const Root = () => {
const isAuthenticated = () => { ... };
return (
<>
{isAuthenticated() ? (
<>
<Nav />
</>
) : undefined}
<Outlet />
<React.Suspense>
<TanStackRouterDevtools />
</React.Suspense>
</>
);
}; |
Beta Was this translation helpful? Give feedback.
3 replies
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.
-
I would like to conditionally hide the navbar in some of the pages of my app. I didn't find a direct way to do this in the docs.
I have a Vite React app with the following set up.
routes/__root.tsx
routes/login.lazy.tsx
src/pages/LoginPage.tsx
By default, the navbar from
__root.tsx
is visible on the pages for all my routes. I would like to hide this navbar in my LoginPage.Is it possible to do this with TanStack router?
Beta Was this translation helpful? Give feedback.
All reactions