renderToStaticMarkup() — astro Function Reference
Architecture documentation for the renderToStaticMarkup() function in server.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 1a376583_017c_cfcf_84e2_0bfbbc11de09["renderToStaticMarkup()"] 88d29d84_fc17_43e9_f02f_9b64acf73dd5["server.ts"] 1a376583_017c_cfcf_84e2_0bfbbc11de09 -->|defined in| 88d29d84_fc17_43e9_f02f_9b64acf73dd5 46a0099c_2704_e054_25d0_ddd9bfde5d46["slotName()"] 1a376583_017c_cfcf_84e2_0bfbbc11de09 -->|calls| 46a0099c_2704_e054_25d0_ddd9bfde5d46 6bbf5900_ad67_3487_cd24_55eedabbb184["needsHydration()"] 1a376583_017c_cfcf_84e2_0bfbbc11de09 -->|calls| 6bbf5900_ad67_3487_cd24_55eedabbb184 4c527789_d4d5_d58b_c232_06c54369f406["getFormState()"] 1a376583_017c_cfcf_84e2_0bfbbc11de09 -->|calls| 4c527789_d4d5_d58b_c232_06c54369f406 12bdf019_29a8_a98c_ae78_320a470374b2["renderToReadableStreamAsync()"] 1a376583_017c_cfcf_84e2_0bfbbc11de09 -->|calls| 12bdf019_29a8_a98c_ae78_320a470374b2 6c90a0ed_3f34_1253_b029_1e3fe08eeb94["renderToPipeableStreamAsync()"] 1a376583_017c_cfcf_84e2_0bfbbc11de09 -->|calls| 6c90a0ed_3f34_1253_b029_1e3fe08eeb94 style 1a376583_017c_cfcf_84e2_0bfbbc11de09 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/react/src/server.ts lines 66–125
async function renderToStaticMarkup(
this: RendererContext,
Component: any,
props: Record<string, any>,
{ default: children, ...slotted }: Record<string, any>,
metadata?: AstroComponentMetadata,
) {
let prefix;
if (this && this.result) {
prefix = incrementId(this.result);
}
const attrs: Record<string, any> = { prefix };
delete props['class'];
const slots: Record<string, any> = {};
for (const [key, value] of Object.entries(slotted)) {
const name = slotName(key);
slots[name] = React.createElement(StaticHtml, {
hydrate: needsHydration(metadata),
value,
name,
});
}
// Note: create newProps to avoid mutating `props` before they are serialized
const newProps = {
...props,
...slots,
};
const newChildren = children ?? props.children;
if (children && opts.experimentalReactChildren) {
attrs['data-react-children'] = true;
const convert = await import('./vnode-children.js').then((mod) => mod.default);
newProps.children = convert(children);
} else if (newChildren != null) {
newProps.children = React.createElement(StaticHtml, {
hydrate: needsHydration(metadata),
value: newChildren,
});
}
const formState = this ? await getFormState(this) : undefined;
if (formState) {
attrs['data-action-result'] = JSON.stringify(formState[0]);
attrs['data-action-key'] = formState[1];
attrs['data-action-name'] = formState[2];
}
const vnode = React.createElement(Component, newProps);
const renderOptions = {
identifierPrefix: prefix,
formState,
};
let html: string;
if (opts.experimentalDisableStreaming) {
html = ReactDOM.renderToString(vnode);
} else if ('renderToReadableStream' in ReactDOM) {
html = await renderToReadableStreamAsync(vnode, renderOptions);
} else {
html = await renderToPipeableStreamAsync(vnode, renderOptions);
}
return { html, attrs };
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does renderToStaticMarkup() do?
renderToStaticMarkup() is a function in the astro codebase, defined in packages/integrations/react/src/server.ts.
Where is renderToStaticMarkup() defined?
renderToStaticMarkup() is defined in packages/integrations/react/src/server.ts at line 66.
What does renderToStaticMarkup() call?
renderToStaticMarkup() calls 5 function(s): getFormState, needsHydration, renderToPipeableStreamAsync, renderToReadableStreamAsync, slotName.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free