T
TanStack2y ago
xenophobic-harlequin

Router NotFoundRoute not working in File-Based routing

CC this discussion: https://github.com/TanStack/router/discussions/1013 After digging around and trying various things to get a fallback NotFoundRoute page to load, I had found this discussion in hopes that it would lead me somewhere. I'm met with an impasse, however. My project structure is simple: - /routes - /login - route.tsx - root.tsx - main.tsx In my main.tsx, I follow the docs at https://tanstack.com/router/v1/docs/guide/creating-a-route#not-found-route to set up a fallback for File-Based routing. From the TanStack dev tools: - localhost:5173 - matches `root. Root component is rendered. - localhost:5173/foo - matches root and /404. NotFoundRoute is rendered. - localhost:5173/login - matches (in order) root and /login. Login component is rendered. - localhost:5173/login/foo - matches (in order) root__, /login, and /404`. NotFoundRoute is not rendered, instead the Login component is. I'm struggling to figure out how to get a universal fallback to work without having a catchall at every point in the file route tree.
GitHub
How to use notFoundRoute with file-based routing · TanStack router ...
I've got a pretty basic implementation of the router to give it a POC/test run but I'm struggling to figure out how to implement notFoundRoute in file-based routing. Is there an example ava...
4 Replies
graceful-blue
graceful-blue2y ago
also experiencing this issue right now any advice @Tanner Linsley ?
conscious-sapphire
conscious-sapphire2y ago
Struggling with this issue as well. Found a related issue on GitHub that reports the same problem. https://github.com/TanStack/router/issues/1038
GitHub
404 route is not rendered in child routes that doesn't exists · Iss...
Describe the bug I have two urls / /about I have configured the not-found url but when I go to urls like /about/asdfsadf it renders the about page instead of the 404 error 😢 Your Example Website or...
ambitious-aqua
ambitious-aqua2y ago
We’re in the process of releasing some new, not found APIs that might clear this up. We’ll get those released then address this.
conscious-sapphire
conscious-sapphire2y ago
sure thanks a lot!

Did you find this page helpful?