server-components

Implement and debug TanStack Start React Server Components in React 19 applications.

Updated May 26, 2026
One-click install
npx skills add https://github.com/Albo-Club/albo-os --skill server-components-albo-club
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: server-components
Source: https://github.com/Albo-Club/albo-os/tree/main/.agents/skills/tanstack-react-start/server-components
Command: npx skills add https://github.com/Albo-Club/albo-os --skill server-components-albo-club

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-start, @tanstack/react-router, @tanstack/react-query, @vitejs/plugin-rsc, zod, and includes references (resource) components.

What problem does it solve? TanStack Start treats React Server Components as fetchable React Flight payloads rather than a framework-owned server tree, which makes choosing the right primitive, cache owner, and refresh path confusing. This Skill provides decision rules, invariants, and copy-paste patterns so you implement RSCs correctly the first time. ## Core Features & Use Cases - Primitive selection: Decide between renderServerComponent, createCompositeComponent with client slots, and low-level Flight stream APIs based on composition needs. - Cache and refresh ownership: Choose between Router loader cache, TanStack Query (with structuralSharing: false), and HTTP cache, then wire invalidation to the correct owner. - Debugging and review: Triage setup failures, slot bugs, stale data, serialization errors, and SSR mode issues with dedicated reference docs. - Use Case: You need a server-rendered post card with an interactive moderation button. Use the composite component pattern with a renderActions slot so the server owns the data and the client owns the control. ## Quick Start Ask the assistant to implement a TanStack Start route that renders a server component through a loader and explain which cache owner should handle its refresh.

Frequently Asked Questions about server-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use React Server Components in TanStack Start?

Enable RSC in vite.config with tanstackStart({ rsc: { enabled: true } }) plus @vitejs/plugin-rsc, then return a component from a createServerFn using renderServerComponent and consume it in the route loader. Use createCompositeComponent only when the client must fill slots.

What is the difference between renderServerComponent and createCompositeComponent?

renderServerComponent returns a renderable fragment with no slot support, while createCompositeComponent accepts client-provided children, render props, or component props as placeholders the client fills later. Choose the composite form only when interactivity must sit inside server-rendered markup.

How do I cache TanStack Start RSCs with TanStack Query?

Set structuralSharing: false on the query options so Query does not merge RSC values across fetches, prefetch with ensureQueryData in the loader, and read with useSuspenseQuery. Invalidate with queryClient.invalidateQueries since Query owns freshness.

Why is my TanStack Start RSC showing stale data after a mutation?

Stale data usually means invalidation targeted the wrong cache owner. Use router.invalidate() for loader-owned fragments, invalidateQueries for Query-owned fragments, and bust response headers for HTTP-cached GET server functions.

Can I use Children.map or cloneElement inside a Composite Component?

No, slot payloads are opaque placeholders on the server, so child inspection does nothing useful. Convert the pattern to a render prop that receives explicit serializable data from the server instead.

When should I use ssr: 'data-only' versus ssr: false in TanStack Start?

Use ssr: 'data-only' when the route component needs browser APIs but the loader can still prefetch on the server. Use ssr: false only when the loader itself depends on browser APIs like localStorage or window.