Open History to see the last commit
1import type {
2 RenderableServerComponentBuilder,
3 ValidateRenderableServerComponent,
4} from './ServerComponentTypes'
5β
6/**
7 * Client stub for renderServerComponent.
8 *
9 * This function should never be called at runtime on the client.
10 * It exists only to satisfy bundler imports in client bundles.
11 * The real implementation only runs inside server functions.
12 */
13export function renderServerComponent<TNode>(
14 _node: ValidateRenderableServerComponent<TNode>,
15): Promise<RenderableServerComponentBuilder<TNode>> {
16 // Unit/type tests import this stub directly and call it.
17 // Avoid throwing in that environment while keeping a hard runtime guard elsewhere.
18 if (process.env.NODE_ENV === 'test') {
19 return Promise.resolve(null as any)
20 }
21β
22 throw new Error(
23 'renderServerComponent cannot be called on the client. ' +
24 'This function should only be called inside a server function or route loader.',
25 )
26}