@shadow-js/web/server
The 33 exports of @shadow-js/web/server: 23 functions, 9 interfaces and 1 component.
Everything @shadow-js/web/server exports, from the TSDoc of its entry point.
Functions#
createComponent: Calls a component on the server, untracked, with its own owner and hydration scope, so the hydration keys it hands out depend only on where it sits in the tree.createServerHead: Creates an empty server head collector.createServerPortals: Creates the collector a server render writes its portals into.derived: The server twin of the clientderived, which the compiler emits forconst x = <expression reading signals>inside a component.deserialize: Rebuilds the value serialize wrote, with its shared references and cycles.escape: Converts any value a JSX child may hold to escaped HTML: the helper compiled server output calls for every dynamic child, and what the renderers call on the app's result.generateHydrationScript: Returns the inline<script>that records the events a user makes before the app has hydrated, sohydrate()can replay them once its handlers are attached (a click made while the bundle loads is not lost).memo: The server twin ofmemo: nothing is reactive during a server render, so it computes once, on the first read, and returns the cached value on every later read.mergeProps: Merges props objects into one getter-preserving object.normalizeTags: Normalizes what useHead receives: one description, a list, or nothing.renderToStream: Renders an app as a stream of HTML, for the fastest first byte: the shell first (pending Suspense boundaries show their fallback), then one chunk per boundary as its data arrives, in the order the data settles, and finally, when resources resolved, a<script type="application/json" data-sh="RENDER_ID">block with their values.renderToString: Renders an app to an HTML string synchronously: the simplest server render, for pages whose data is already at hand.renderToStringAsync: Renders an app to an HTML string once its data has loaded: each pass renders with the resource values found so far, the fetches it starts are awaited, and another pass runs while one of them produced a new value.serialize: Serializes data for embedding in a page, as JSON that is safe inside a<script type="application/json">element.ssr: Joins the static parts of a server template with its dynamic holes into trusted markup: the function compiled server output calls for each element tree.ssrAttribute: Renders one attribute as markup with a leading space, or""when the attribute is absent: the helper the compiler's server output calls for a dynamic attribute.ssrClass: Renders aclassattribute from a class value: the helper the compiler's server output calls forclass,classNameandclassList, with the same clsx rules as the client'sclassName.ssrElement: Renders an element from a props object: what compiled server output calls for an element with a spread (<div {...props} />), and the server half ofDynamicandelement.ssrHydrationKey: Draws the next hydration key of the current scope and returns it as adata-hkattribute, such as' data-hk="0-0"': compiled server output calls it for the root element of each template, and the client'shydrate()claims the element by that key.ssrRaw: Marks a string as trusted markup thatescapeandssrinsert unchanged.ssrSelectValue: The options of a<select>with the ones its value stands for markedselected.ssrStyle: Renders astyleattribute from a style value: the helper the compiler's server output calls forstyleandstyle:attributes.ssrTextArea: Renders the content of a<textarea>from its value: the helper compiled server output calls for<textarea value={...}>anddefaultValue, since a browser ignores avalueattribute on a textarea.
Interfaces#
AsyncRenderOptions: Options of renderToStringAsync: the RenderOptions plus the limits of the multi-pass render.AsyncRenderResult: What renderToStringAsync resolves to: the markup and the resource data to embed for hydration.Derived: The server twin of the clientDerived: what derived returns.HydrationScriptOptions: Options of generateHydrationScript and HydrationScript.NormalizedTag: A validated tag: lower-case attribute names, the text it carries, and its identity.RenderOptions: Options of renderToString, and the base of AsyncRenderOptions.ServerHead: The head of one server render: whatuseHead,<Title>,<Meta>,<Link>,<Style>and<Base>registered while the app rendered.ServerPortals: The markup of the portals a server render produced (see createServerPortals).StreamOptions: Options of renderToStream.
components#
HydrationScript: generateHydrationScript as a component, for a document rendered with server JSX:<HydrationScript nonce={nonce} />in the<head>.