server-components

Implement, review, debug, and refactor TanStack Start React Server Components in React 19 apps. Use when tasks mention @tanstack/react-start/rsc, renderServerComponent, createCompositeComponent, CompositeComponent, renderToReadableStream, createFromReadableStream, createFromFetch, Composite Components, React Flight streams, loader or query owned RSC caching, router.invalidate, structuralSharing: false, selective SSR, stale names like renderRsc or .validator, or migration from Next App Router RSC patterns. Do not use for generic SSR or non-TanStack RSC frameworks except brief comparison.

Install
npx skills add 'https://github.com/TanStack/router/tree/main/packages/react-start/skills/react-start/server-components'
Download bundle ↓
main · 8e164d2Scanned 2026-09-15

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md
// Selective SSR: the loader fetches the RSC on the server,// but the route component renders on the client because it needs browser APIs. import * as React from 'react'import type { ReactNode } from 'react'import { createFileRoute } from '@tanstack/react-router'import { createServerFn } from '@tanstack/react-start'import {  CompositeComponent,  createCompositeComponent,} from '@tanstack/react-start/rsc' // Replace with your own server-side data sourcedeclare function getDashboardStats(): Promise<{  series: Array<{ x: number; y: number }>  totalUsers: number}> const getDashboard = createServerFn({ method: 'GET' }).handler(async () => {  const stats = await getDashboardStats()   const src = await createCompositeComponent<{    renderChart?: (args: {      series: Array<{ x: number; y: number }>    }) => ReactNode  }>((props) => (    <section>      <h1>Users: {stats.totalUsers}</h1>      {props.renderChart?.({ series: stats.series })}    </section>  ))   return { src }}) export const Route = createFileRoute('/dashboard')({  ssr: 'data-only',  loader: async () => ({    Dashboard: await getDashboard(),  }),  component: DashboardPage,}) function DashboardPage() {  const { Dashboard } = Route.useLoaderData()  const [width, setWidth] = React.useState(0)   React.useEffect(() => {    setWidth(window.innerWidth)  }, [])   return (    <CompositeComponent      src={Dashboard.src}      renderChart={({ series }) => (        <ResponsiveChart data={series} width={width} />      )}    />  )} // Replace with your real chart componentfunction ResponsiveChart(props: {  data: Array<{ x: number; y: number }>  width: number}) {  return (    <pre>      {JSON.stringify({ width: props.width, points: props.data.length })}    </pre>  )} 
Referenced from SKILL.md