TanStackT
TanStack9mo ago
15 replies
popular-magenta

Is it possible to render the notFoundComponent inside of my auth only layout?

Please take a look at this adjusted kitchen sink example: https://stackblitz.com/edit/tanstack-router-mg97mijn?file=src%2Froutes%2F__root.tsx
My app has a setup like this:
- _auth folder for routes only visible after login which has the navbar in the layoutless route
- _login folder for routes only visible before login which has the login page layout in the layoutless route

Please take a look at the stackblitz link. I've added an invalid lik to the /page which is visible after login, navigating to the link shows the not found component but it's full screen. If the user is logged in, the 404 page should be displayed inside of the logged in layout in order for the navbar and so on to be visible. Is this possible or do I need to adjust my routing approach?
Thank's a lot
StackBlitzreihwald
Run official live example code for Router Kitchen Sink File Based, created by Tanstack on StackBlitz
404 - StackBlitz
Was this page helpful?