TanStack Start & TanStack Query

4 hours, 23 minutes CC
TanStack Start & TanStack Query

Course Description

Build production-ready apps with TanStack! Explore the full ecosystem, from Router to Start to Query, while leveraging server-side rendering, type-safe routing, caching strategies, and React Server Components. Walk away with the skills to ship high-performance full-stack React apps.

Prerequisite: Complete Intro to React or experience building fullstack applications.
Preview
4.6 rating
Was a great overview of the framework. Excited to start using in my own projects and projects at work.

Course Details

Published: June 10, 2026

Rating

4.6

Learn Straight from the Experts Who Shape the Modern Web

Your Path to Senior Developer and Beyond
  • 300+ In-depth courses
  • 24 Learning Paths
  • Industry Leading Experts
  • Live Interactive Workshops

Table of Contents

Introduction

Section Duration: 15 minutes
  • Introduction
    Adam Rackis introduces TanStack Start, covering course requirements and the workout tracking app's key features, with setup requiring only Node and NPM (plus optional Docker for a persistent database). He also explains the distinction between TanStack Router and TanStack Start, highlighting how Start extends Router with server-side support for improved performance and reduced network round trips compared to single-page applications.

Setup

Section Duration: 37 minutes
  • Drizzle Overview
    Adam introduces Drizzle, his favorite ORM, explaining how it adds TypeScript static type checking on top of SQL. He walks through setting up Drizzle with a config file and demonstrates how DrizzleKit efficiently queries workouts, sets, and exercises in a SQL-like syntax.
  • Routing Basics
    Adam explains the difference between flat file and directory routes in TanStack Router, covering how routes are structured and organized. He demonstrates setting up and validating search parameters and navigating using TanStack Router's strongly typed functions.
  • Loaders
    Adam demonstrates how to add a loader to a route and retrieve dynamic data using the useLoaderData hook, emphasizing the need to avoid circular dependencies. He discusses the isomorphic nature of loaders in TanStack Start, highlighting how running on both server and client improves SEO and user experience.
  • Routing Errors & 404 Handling
    Adam introduces TanStack Router's not found component, which automatically renders when routing to an invalid URL, and demonstrates how to programmatically trigger it for errors like invalid workout template IDs. He also shows how to customize the component with specific error messages to improve the handling of 404 errors.

Server Functions

Section Duration: 1 hour
  • Loading Data
    Adam introduces server functions in TanStack, explaining how they run exclusively on the server for safe execution of server-only utilities like Postgres drivers. He demonstrates creating strongly typed server functions using createServerFunction and showcases TanStack's built-in loading indicators like pendingComponent and pendingMinMilliseconds.
  • Route Caching
    Adam introduces route caching in TanStack Router, explaining how stale time and garbage collection time properties control whether data is cached or refetched. He demonstrates how to invalidate the cache by reloading specific routes or clearing it entirely for a better user experience.
  • Layout Rendering & Refetching
    Adam introduces loading data in layouts, demonstrating how to add a loader and access data using useLoaderData to avoid unnecessary backend requests. He also covers pathless layouts as a way to organize routes without affecting the URL structure.
  • Streaming
    Adam explains the benefits of server-side rendering for delivering initial content faster than single-page applications. He demonstrates implementing streaming by returning promises from the loader, which the framework resolves and pushes down to the client when ready.
  • Streaming with Suspense
    Adam demonstrates implementing Suspense in React 19 by wrapping components in a suspense tag with a fallback, using the new use hook to block rendering until promises resolve. He emphasizes strategically placing suspense boundaries in the component tree to balance efficient data loading with a smooth user experience.

TanStack Query

Section Duration: 39 minutes
  • TanStack Query
    Adam introduces TanStack Query, explaining key components like the useQuery hook, query key, and query function, and demonstrating how stale time and GC time control data freshness. He also shows how to invalidate active queries while removing inactive ones from the cache to prevent stale data.
  • Suspense & TanStack Query
    Adam demonstrates integrating TanStack Query with TanStack Router for server-side rendering, showing how to access the query client in the loader using reusable query options functions. He highlights how isomorphic loaders in TanStack Start seamlessly hydrate server-loaded data into client components.
  • Blocking Suspense Rendering
    Adam explains how to integrate Suspense with TanStack Query using useSuspenseQuery to block rendering until data is ready, and demonstrates using React 19's useTransition hook to prevent full page unloads during pagination. This combination provides a smoother user experience when handling loading states and transitions.
  • Opt-In String Query Params
    Adam demonstrates paging data with the page stored in the URL, explaining how to use loaderDeps to rerun the loader when query string parameters change and useDeferredValue to manage suspensions during transitions. He concludes by summarizing data loading topics covered and addressing error handling in production using React error boundaries and robust logging systems.

Middleware

Section Duration: 50 minutes
  • Middleware
    Adam introduces middleware, demonstrating how to attach it to server functions and run code on both client and server sides. He walks through passing arguments to middleware and stacking multiple middlewares to showcase the order of execution in the chain.
  • Sending Middleware Context
    Adam explains how context values in middleware stay within their respective client or server sides unless explicitly sent across using the sendContext property. He demonstrates restructuring middleware functions to ensure proper type flow, allowing values to be accessed across client and server callbacks.
  • Server-Side Middleware Function
    Adam demonstrates how server functions interact with the middleware chain, walking through the sequential execution of code and the flow of control between client and server sides. He explains how the presence of client callbacks determines how control moves through the middleware during server function invocation.
  • Real World Middleware
    Adam introduces a basic logging middleware that records start and end times on both client and server sides, using a trace ID to link related events. He demonstrates sending context between client and server in a simplified example to help students understand core middleware concepts.
  • Advanced Middleware