How to nested a 404 and 500 page?
Hi everyone, I'm working with TanStack Router and trying to implement different 404 and 500 error pages for different layouts. I have a
__root.tsx layout and a _protected.tsx layout.
My goal is to have a specific 404 page rendered when a route under the _protected layout is not found, without falling back to the 404 defined in __root.tsx.
Currently, I've tried defining a notFoundComponent within _protected.tsx. However, when I navigate to a non-existent route within the _protected layout, it always renders the notFoundComponent defined in __root.tsx instead.
Here's my route structure for context:
here is my route
Is there a specific way to achieve this nested 404 behavior? I'm assuming the notFoundComponent in _protected.tsx should override the root one for routes under that layout, but it's not working as expected. Any ideas on what I might be missing or how to correctly implement this?"3 Replies
afraid-scarlet•9mo ago
Hi
I am interested on your post.
I can help you.
thanks.
genetic-orangeOP•9mo ago
so? how?
noble-gold•9mo ago
probably spam
can you create a minimal complete example by forking one of the existing examples on Stackblitz?
then it's much easier to experiment