
Discover how TanStack Router delivers a 100% type-safe routing library for React, with auto-completion, json-style search parameters, built-in data loading, caching, and file-based automatic route generation from a routes folder.
Learn how TanStack Router uses a root route as the top-level parent in a single-page React app, with file-based routing that auto-generates the root route after running npm run dev.
Set up the tanstack router by creating router.tsx, importing createRouter, wiring the generated routeTree from routeTree.gen, exporting the router, and wrapping the app with RouterProvider.
Create the index route as the default base URL route using index.tsx in the routes folder with the create file route function, and add a portal route for /portal.
TanStack Router auto-generates a typed route tree from your route files, linking routes to their parents and updating routeTree.gen.ts as changes occur, without manual edits.
Explore how the outlet component acts as a placeholder to render the active child route inside the root route, enabling nested routing with portal, profile, and index.
Learn to build a responsive navigation bar using TanStack Router, Bootstrap styling, and link components to navigate between routes without full page reloads, with type-safe route names.
Discover styling active links in TanStack Router by using inline styles or an active class, and render a different icon with isActive (PiUserFill vs PiUser) for the profile route.
Explore creating nested routes within a portal, including a default index route and child routes like posts and todos, using outlet rendering and fragments to display active content.
Create a portal layout route with a PortalMenu for navigating child routes, ensure exact active matching so only the portal link is active, and render nested routes via Outlet.
Implement a TanStack Router nested profile layout with index and edit routes, a profile menu using react-icons to show active filled icons and inactive outlines, and a layout with outlet.
Compare flat routes and directory routes, convert dots to folders with a forward slash, and mix approaches while organizing portal, profile, index, posts, and todos.
Create dynamic routes for posts using a dynamic segment postId nested inside posts with an outlet. Access postId via params with use parents hook for a clean, type safe route.
Rename the post route file and add an underscore after posts to turn a nested route into a non-nested sibling route, enabling separate pages for post details.
Create a custom not found component for TanStack router, replace the inline function with a dedicated NotFound.tsx, and apply it globally or per route to handle invalid paths.
Explore using a loader to supply real data in routes, fetch data with Axios, manage loading and error states, and preview route masking.
Use a loader to fetch posts from json placeholder API, show how to fetch via Axios, handle promises with async/await, and access the data array of post objects before rendering.
Learn to render posts in a TanStack Router route by returning loader data and using use loader data to map posts into a list with post.title and post.id keys.
Learn how to cancel ongoing data fetches in TanStack Router when a user navigates away from a route, by using an abort controller in the loader, ensuring requests stop automatically.
Learn to handle errors in TanStack Router by using on-error and the error component props to log messages, show details, and enable reset to retry the loader.
Learn to display a loading spinner during data fetches using pendingComponent, bootstrap's spinner, and configure pendingMs and pendingMinMs for smooth feedback.
Fetch a specific post using the postId path parameter with a loader and axios. Define the post interface, build a dynamic endpoint, and render the post title and body.
Configure default fallback components in the router file to apply to all routes, using the default error component and default pending component with global timing. Override per-route defaults when needed.
Fetch and render todos from the JSON placeholder API using a loader with axios, displaying each todo’s title and status (completed or todo) in a styled list.
Learn to create a nested comments route inside postId, render it via outlet, and navigate programmatically with useNavigate by clicking a button, passing postId as a string.
Explore conditional navigation with TanStack Router by using the useLocation hook to read the pathname, detect /comments, and navigate to show or hide comments accordingly.
Learn when to use useNavigate vs Link in TanStack Router, prefer Link for known destinations and UI navigation, and convert a button to Link with to and params.
Fetch comments for a specific post by using a postId query parameter with axios in a TanStack Router loader, pulling postId from route params and rendering filtered comments.
Apply route masking in TanStack Router to keep URLs clean by hiding the comments path, configure masks in the link component, and centralize masks in the router for easier maintenance.
Create a reusable api client in services/apiClient.ts, configure it with a base URL, export a default instance, and replace axios with apiClient across posts, postId, comments, and todos routes.
Refactor the posts feature by moving api calls into a dedicated post service with get all posts and get post by id, using abort signal to keep routes clean.
Build and use two api services for todos and comments, with getAllTodos and getCommentsByPostId methods, using apiClient and abortSignal, exporting default service instances in routes.
TanStack Router - The Practical Guide
This course is for React developers that want to learn TanStack Router without wasting time. Get all the foundations you need in this 5-hour course and start building apps with TanStack Router as soon as possible.
Once enrolled, I will walk you through all the fundamentals, so you can go from zero to building scalable and type-safe routing in React applications.
We will go hands-on from the start by building a full web app from scratch. You will learn by doing as you work through each concept in a real project.
Learn how TanStack Router works and how it integrates with popular React libraries like Zod, Axios and Zustand. Improve your app's performance by using built-in features like caching and preloading. Practice what you learn through exercises, then watch a detailed video breakdown of the solution if needed!
By the end of the course, you will be confident setting up routing in your own React applications.
What’s next?
Learn how to build full stack apps with TanStack Start. Once you understand TanStack Router, you already have most of the knowledge needed to get started with TanStack Start, a framework built directly on top of it.