// 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 source
declare 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) => (