Open History to see the last commit
1/// <reference types="vite/client" />
2/// <reference types="@vitejs/plugin-rsc/types" />
3import * as React from 'react'
4import { serverBadge, serverBox, serverHeader, timestamp } from './serverStyles'
5import { ClientWidgetA } from './ClientWidgetA'
6β
7// ============================================================================
8// COMPLEX PRELOAD: Server component A content with client widget A
9// This is a pure server component file (no createServerFn) so vite-plugin-rsc's
10// CSS transform can properly wrap the exported component
11// ============================================================================
12β
13export function ComplexPreloadContentA({
14 data,
15 children,
16}: {
17 data: { title: string }
18 children?: React.ReactNode
19}) {
20 const serverTimestamp = Date.now()
21β
22 return (
23 <div style={serverBox} data-testid="server-component-a">
24 <div style={serverHeader}>
25 <span style={serverBadge}>SERVER COMPONENT A</span>
26 <span style={timestamp} data-testid="server-a-timestamp">
27 Fetched: {new Date(serverTimestamp).toLocaleTimeString()}
28 </span>
29 </div>
30β
31 <h2
32 style={{ margin: '0 0 16px 0', color: '#0c4a6e' }}
33 data-testid="server-a-title"
34 >
35 {data.title}
36 </h2>
37β
38 <p style={{ margin: '0 0 16px 0', color: '#0369a1', fontSize: '14px' }}>
39 This server component renders ClientWidgetA directly and accepts
40 ClientWidgetB via children slot.
41 </p>
42β
43 {/* ClientWidgetA rendered DIRECTLY inside server component */}
44 <ClientWidgetA title="Widget A (Direct)" />
45β
46 {/* ClientWidgetB passed via children slot from route component */}
47 <div data-testid="server-a-slot">{children}</div>
48 </div>
49 )
50}