T
TanStack•3y ago
aware-green

Is it possible to remove the trailing slash?

My route tree is setup like whats in the picture below. When going to the "search page" the generated route is /agreements/ and when using search params, it comes out to something similar to /agreements/?page=1&size=10. Similarly, when navigating to the item page, the generated url looks like /agreements/12345/. Is it possible to remove that trailing slash to get routes to look like /agreements , /agreements?page=1&size=10, and /agreements/12345?
No description
6 Replies
aware-green
aware-greenOP•3y ago
Looks like if I directly add the value for the to prop (eg: to='/agreements') and not derive the value from the route configuration file (eg: to={searchPage.to}), then it is ok.
metropolitan-bronze
metropolitan-bronze•2y ago
I would like to have the opposite 😂 - to have trailing slashes everywhere with file based routing but I also see right now that it's mixed - everything is without trailing slash, but a trailing slash is appended as soon as I add query params: so /foo becomes /foo/?myParam=bar as soon as I navigate to that route with a search param oh right, that was just because I had my navigate call wrong. it seems that both are valid typescript:
navigate({ to: "/foo" })
navigate({ to: "/foo/" })
navigate({ to: "/foo" })
navigate({ to: "/foo/" })
is that on purpose ?
ratty-blush
ratty-blush•2y ago
depends on whether you have an index route configured or not
metropolitan-bronze
metropolitan-bronze•2y ago
You mean an index route under /foo ?
ratty-blush
ratty-blush•2y ago
yes
metropolitan-bronze
metropolitan-bronze•2y ago
Not an index route, but it's a directory with a route.tsx and a $id.tsx

Did you find this page helpful?