T
TanStack13mo ago
national-gold

Question about route conflicts

Hello. With file-based routing, how can I achieve: /items - $itemId.tsx - new.tsx new.tsx seems to be conflicting with the param route
5 Replies
extended-salmon
extended-salmon13mo ago
It shouldn't, just creating the following files should do the trick.
src/routes
items/
$itemId.tsx
new.tsx
src/routes
items/
$itemId.tsx
new.tsx
It gives you the following URLs. - /items/$itemId - /items/new Your /items/new route won't conflict with the /items/$itemId route since the sorting would first try to match it with the new route before evaluvating it as the $itemId param route.
extended-salmon
extended-salmon13mo ago
If you are still having difficulties with this, please fork the Quickstart Stackblitz example to setup the kind of routing you are looking for. https://stackblitz.com/github/tanstack/router/tree/main/examples/react/quickstart-file-based?file=src/main.tsx
StackBlitz
Router Quickstart File Based Example - StackBlitz
Run official live example code for Router Quickstart File Based, created by Tanstack on StackBlitz
national-gold
national-goldOP13mo ago
Huh, it works now with 0 changes I guess the route gen had a hiccup
extended-salmon
extended-salmon13mo ago
¯\_(ツ)_/¯
national-gold
national-goldOP13mo ago
Thanks anyway

Did you find this page helpful?