Lesson
Create a new Route in Tanstack Router
Create new routes in TanStack Router by adding files to the routes directory for automatic route file generation.
- Access
- Included
- Transcript
- Needs source
In this lesson, we learn how to create a new route in TanStack Router by simply adding a new file to the routes directory.
For example, creating an employees.tsx file automatically generates a new route, which is reflected in the routeTree.gen.tsx file.
We explore how to define the root component within this new file and how to link to it from other components using the <Link> component.
The lesson highlights the benefits of type safety provided by TypeScript, which helps catch typos and ensures that only valid routes are used. This approach streamlines the process of adding new routes and maintaining a robust routing system.