Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

cssModulesServerComponent.tsx

19 lines829 Bytes

1import { createServerFn } from '@tanstack/react-start'
2import { renderServerComponent } from '@tanstack/react-start/rsc'
3// Import the component from a separate file so vite-plugin-rsc's CSS transform
4// can properly wrap it (without interference from server function splitting)
5import { CssModulesContent } from './CssModulesContent'
6​
7// ============================================================================
8// Server function that returns the CSS Modules server component
9// ============================================================================
10​
11export const getCssModulesServerComponent = createServerFn({ method: 'GET' })
12 .validator((data: { title?: string }) => data)
13 .handler(async ({ data }) => {
14 return renderServerComponent(
15 <>
16 <CssModulesContent data={data} />
17 </>,
18 )
19 })