T
TanStack16mo ago
conscious-sapphire

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
rising-crimson
rising-crimson16mo 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.
rising-crimson
rising-crimson16mo 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
conscious-sapphire
conscious-sapphireOP16mo ago
Huh, it works now with 0 changes I guess the route gen had a hiccup
rising-crimson
rising-crimson16mo ago
¯\_(ツ)_/¯
conscious-sapphire
conscious-sapphireOP16mo ago
Thanks anyway

Did you find this page helpful?