TanStack.com Documentation Hub

repository·main·Indexed 21 days ago

https://github.com/tanstack/tanstack.com

The central documentation hub for the TanStack ecosystem, built with TanStack Router and deployed on Cloudflare Workers. This repository contains the site source, documentation authoring guidelines for using framework, bundler, and package-manager tabs, and the MCP Documentation Discoverability Evaluation tool for testing AI assistant search relevance.

Tokens
116.2K
Snippets
269
Records
506
Agent score
76%

What's inside tanstack.com

  1. Overview of TanStack AI Alpha

    main

    TanStack AI is a framework-agnostic AI toolkit designed to prevent vendor and ecosystem lock-in. It provides a set of open-source libraries that allow developers to build AI applications using their existing stack rather than being forced into a specific cloud provider or framework.

    Key Features

    • Multi-language Server Support: Support for JavaScript/TypeScript, PHP, and Python (including full agentic flows with tools).
    • Provider Adapters: TypeScript adapters for OpenAI, Anthropic, Gemini, and Ollama.
    • Open Protocol: A documented communication protocol between server and client that works over any transport layer (HTTP, WebSockets, etc.).
    • Isomorphic Tool Support: Define tools once using meta-definitions to provide type safety across both server and client implementations.
    • Client Libraries: Available for Vanilla JS, React, and Solid (with Svelte and others coming soon).
    • Per-model Type Safety: Full typing for providerOptions on a per-model basis, accounting for different modalities like text, audio, video, and tools.
    • Isomorphic Devtools: A dedicated AI devtools panel (built on TanStack Devtools) to debug LLM workflows on both the client and server sides.
  2. New features in TanStack DB 0.6

    main

    TanStack DB 0.6 introduces several new capabilities for application data management:

    • Includes: Allows projecting normalized data into hierarchical structures that match your UI (similar to GraphQL, but without new infrastructure).
    • createEffect: Provides reactive side effects for workflows, tools, and agent-style automation.
    • Virtual Props: Introduces $synced and $origin props for managing outbox views, sync indicators, and row provenance.
    • queryOnce: Enables one-shot queries using the same syntax as live queries.
    • Opt-in Indexes: Indexes are no longer implicit and must be opted into.
    • Explicit Mutation Handlers: Mutation handlers no longer rely on implicit return behavior.
  3. Key improvements in TanStack Table V9

    main

    TanStack Table V9 introduces several foundational changes focused on performance, state management, and developer experience. Key features include:

    • State Management: Uses TanStack Store, following React's rules and playing well with the React Compiler and other JavaScript frameworks.
    • Granular Re-rendering: Controlled via selectors and Subscribe to prevent unnecessary renders.
    • Performance: Improved memory and CPU usage, specifically optimized for large virtualized tables.
    • Tree-shakability: Features are tree-shakable, ensuring your bundle size only includes what you actually use.
    • Extensibility: Custom features can plug into the same system as built-in features.
    • Code Organization: Introduces createTableHook and tableOptions to make reusable table code easier to organize.
    • Devtools: Official, supported Devtools are available.
  4. Key benefits of TanStack Start

    main

    TanStack Start is a framework designed to bridge the gap between server-first architectures and traditional Single Page Applications (SPAs). Its core strengths include:

    • Future-Proof Architecture: Built to natively support React Server Components (RSCs) and streaming. RSCs are treated as server-side state with primitives for caching and invalidation.
    • Hybrid Flexibility: While it uses patterns familiar to Remix or Next.js users (like server functions), it is designed to work equally well for traditional client-side SPAs.
    • Streaming Support: Streaming is baked into the core, allowing for incremental delivery of data and HTML to the client.
    • Integrated Data Flow: Provides a unified experience for managing data between the server and client, particularly when used alongside TanStack Router and TanStack Query.
  5. Key benefits of TanStack Router

    main

    TanStack Router is a type-safe routing library designed to solve common challenges in modern web development through several core pillars:

    • Contextual Type Safety: Types flow seamlessly through route definitions, parameters, navigation, and state management using TypeScript's natural architecture. This eliminates the need for manual type definitions or AST transformations.
    • URL State Management: The library treats the URL as a primary state management system. It provides APIs to validate, read, and update search parameters with built-in type safety and runtime validation, making app state easily shareable and bookmarkable.
    • Scalable Routing: Designed to handle complex, deeply nested route hierarchies and thousands of routes without performance degradation.
    • Deep Data Integration: Specifically optimized to work with TanStack Query, allowing for seamless prefetching in route loaders, streaming data to the client, and on-demand hydration.
  6. Key features of TanStack Start v1

    main

    TanStack Start v1 includes the following core capabilities:

    • Type-safe, file-based routing: Powered by TanStack Router.
    • Server-first ergonomics: Utilizes isomorphic server functions.
    • Built-in streaming: Supports streaming data; React Server Components (RSC) support is planned as a non-breaking v1.x addition.
    • URL-as-state primitives: Provides runtime validation and full type-safety for URL-based state.
    • SPA and SSR DX: Designed for high developer experience in both Single Page Application and Server Side Rendering modes without opaque magic or lock-in.
    • Deep Query integration: Seamless integration with TanStack Query for prefetching, caching, and hydration.
  7. Overview of TanStack AI

    main

    TanStack AI is a TypeScript-first, framework-agnostic, and provider-agnostic SDK designed for building AI-powered applications without vendor lock-in. It focuses on portability, allowing developers to switch providers without bending their application architecture around a specific SDK.

    Key features include:

    • Typed Tools & Structured Output: Ensures type safety when interacting with AI models.
    • Streaming UI: Built-in support for streaming responses to the UI.
    • Primitives: Includes media and realtime primitives.
    • Extensibility: Supports middleware and orchestration.
    • Architecture: Uses an AG-UI-native wire story that avoids forcing applications through a hosted gateway.
  8. Overview of TanStack Start

    main

    TanStack Start is a full-stack React framework designed to provide a seamless transition from Single Page Applications (SPA) to Server-Side Rendering (SSR) and server-heavy workflows. It is built on top of TanStack Router, leveraging its type-safe route model as the foundation.

    Key features include:

    • TanStack Router Integration: Uses Router's type-safe routes, search params, loaders, pending states, links, and navigation.
    • Full-stack Capabilities: Adds full-document SSR, streaming, server functions, and server routes.
    • Deployment & Bundling: Includes bundling and deployable output.
    • Performance & Compatibility: Supports Rsbuild and features high SSR throughput and experimental React Server Components (RSC) support.
  9. What is TanStack DB and how does it relate to TanStack Query?

    main

    TanStack DB is a client-side database layer powered by differential dataflow that sits on top of TanStack Query.

    While TanStack Query manages the fetching and caching of server state (how to get data), TanStack DB manages the coherence and reactivity of that data once it is in the client (how to keep it fast and relational).

    Key concepts:

    • Collections: Wrappers around useQuery calls (REST, tRPC, GraphQL, etc.) that hold normalized data.
    • Transactions: Allow for optimistic mutations; if a mutation fails, the state rolls back automatically.
    • Live Queries: Declarative queries that use differential dataflow to stream only the specific rows that changed, providing sub-millisecond updates.

    This architecture allows you to move from view-specific API endpoints (Option A) or heavy client-side filtering (Option B) to a model of Normalized Collections + Incremental Joins (Option C), where you load data once and perform lightning-fast joins in the browser.

  10. Connect Generation Hooks via Server Function Streaming

    main

    Server Function Streaming combines the type safety of server functions with the real-time feedback of streaming. It is optimized for TanStack Start.

    How it works: If your fetcher returns a Response object (an SSE stream), TanStack AI automatically detects it and parses the stream in real-time. If it returns anything else, it is treated as a direct result. This allows you to keep your input parameter fully typed while still receiving real-time progress events.

    Server implementation:

    export const generateImageStreamFn = createServerFn({ method: 'POST' })
      .validator(z.object({ prompt: z.string() }))
      .handler(({ data }) =>
        toServerSentEventsResponse(
          generateImage({
            adapter: openaiImage('gpt-image-1'),
            prompt: data.prompt,
            stream: true,
          }),
        ),
      )

    Client implementation:

    const { generate, result, isLoading } = useGenerateImage({
      fetcher: (input) => generateImageStreamFn({ data: input }),
    })
    // Client
    const { generate, result, isLoading } = useGenerateImage({
      fetcher: (input) => generateImageStreamFn({ data: input }),
    })
    
    // Server
    export const generateImageStreamFn = createServerFn({ method: 'POST' })
      .validator(z.object({ prompt: z.string() }))
      .handler(({ data }) =>
        toServerSentEventsResponse(
          generateImage({
            adapter: openaiImage('gpt-image-1'),
            prompt: data.prompt,
            stream: true,
          }),
        ),
      )
  11. How reactivity works in TanStack Table V9

    main

    In TanStack Table V9, reactivity is decoupled from the Table APIs and sits underneath them. This allows different framework adapters to connect state and option reads to their respective reactive primitives.

    Signal-Native Adapters (e.g., Solid)

    In signal-native environments, calling a Table method (like table.getPageCount()) inside a tracked scope (component, computed, or effect) automatically registers the dependency. The framework updates only the specific reactive scope that performed the read.

    React Adapter

    Because React does not collect signal reads during render, the React adapter uses @tanstack/react-store.

    • Default Behavior: useTable subscribes to every registered state slice. Any change schedules a re-render of the component using the hook.
    • Granular Updates: You can pass a selector as the second argument to useTable to narrow the subscription, or use the Subscribe component to create localized update boundaries.
  12. How TanStack AI achieves framework agnosticism

    main

    TanStack AI uses an open, published protocol for server-client communication. This allows you to use any programming language for your backend and any transport layer for communication.

    As long as your backend implementation speaks the TanStack AI protocol through a connection adapter, the client libraries (Vanilla JS, React, Solid) will be able to interact with it. This enables scenarios such as:

    • A PHP Slim backend with a Vanilla JS client.
    • A Python FastAPI backend with a Vanilla JS frontend.
    • A TanStack Start (React/Solid) application using WebSockets or Cap'n'Web RPC.