How to Create a Catch-All Splat Route in TanStack Start
A route file named $.tsx catches the rest of the address, and the route’s params hold it under _splat.
- React.js
- TanStack Start
A route file named $.tsx catches the rest of the address, and the route’s params hold it under _splat.
{-$name} in a route file’s name makes that part of the address optional, so one route matches with or without it.
To link to a route with a path param, give Link the route’s path in to and the value in params.
A $ in a route file’s name makes that part of the address a path param, and Route.useParams() reads its value.
Part 4 gives every book in the Bookshop its own page from one route file, links to it with params, and sends a real 404 for a book that doesn’t exist.
Every rule that turns a file name in src/routes into a page address, from index.tsx and $bookId to _ layouts, (groups) and [ ] escapes, shown with a real route tree.