Course lesson 07 · Building in a Mono Repo
React + Tanstack + TRPC on Workers
The user application pairs React with TanStack Router, TanStack Query, and a tRPC backend deployed as a Worker. The lesson traces a dashboard table from its route loader to a query hook and then to the server procedure, showing how these tools divide navigation, server-data state, and typed communication. At this stage, those procedures still return placeholder data.
Primary source: course video 07 · Supplied English subtitles · 00:14:21.
Understand the idea
- TanStack Router maps route files to pages and runs loaders that can prefetch the data a page needs.
- TanStack Query manages server-data loading, errors, caching, and configured refetch behavior instead of duplicating those concerns in each component.
- A query key identifies cached data, while a query function performs the actual asynchronous data retrieval.
- tRPC supplies a typed client interface and query options, including query keys and functions, for the server procedures.
- The source directory contains the browser application; the worker directory contains the thin backend in the same deployable project.
What the course does
- Run the user application and follow navigation from the landing page to the dashboard.
- Find the dashboard route loader and the top-countries table component that consumes its data.
- Compare manual useEffect-based fetching and state variables with a TanStack Query hook.
- Follow the typed tRPC procedure from the client into the Worker router using editor navigation.
- Identify the dummy result that later database queries will replace, and distinguish ordinary query hooks from the demonstrated suspense-based hook.
Watch for
- Authentication is scheduled for later; the route naming and UI grouping do not prove access is protected yet.
- Added advice: verify retry, caching, and refetch defaults for the installed TanStack version; the instructor’s spoken default retry count is tentative.
- Added advice: compile-time types complement runtime validation; typed client code alone cannot make incoming network data trustworthy.
Recall before revealing
Which tool handles navigation, which handles server-data state, and which supplies the typed backend interface?
Reveal the explanation
TanStack Router handles navigation, TanStack Query handles server-data state, and tRPC connects typed client calls to server procedures.
Try it
Trace one dashboard value through its component, query options, route loader, and server procedure without changing the code.
Check your result
You can point to where the current dummy data originates and where a real database query would be inserted.
Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.
Rewatch only what you need
Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.
- 00:02:01 — File routes and dashboard loaders
- 00:06:00 — Problems in manual fetch state management
- 00:09:00 — tRPC adds typed communication
- 00:11:01 — Trace the table to the Worker backend
Companion primary documentation: tRPC introduction. For recorded API names, commands, limits, and prices, check the version you use.