diff --git a/astro.sidebar.ts b/astro.sidebar.ts index f4424068a970b..f2bcf97c84029 100644 --- a/astro.sidebar.ts +++ b/astro.sidebar.ts @@ -138,6 +138,7 @@ export const sidebar = [ items: [ 'reference/integrations-reference', 'reference/adapter-reference', + 'reference/renderer-reference', 'reference/content-loader-reference', 'reference/image-service-reference', 'reference/dev-toolbar-app-reference', diff --git a/public/_redirects b/public/_redirects index 431a9b1af84bb..c9ed6c8034af6 100644 --- a/public/_redirects +++ b/public/_redirects @@ -56,8 +56,7 @@ # Very old docs site redirects # Once upon a time these URLs existed, so we try to keep them meaning something. -/reference/renderer-reference /en/reference/integrations-reference/ -/en/reference/renderer-reference /en/reference/integrations-reference/ +/reference/renderer-reference /en/reference/renderer-reference/ /en/core-concepts/component-hydration /en/concepts/islands/ /core-concepts/component-hydration /en/concepts/islands/ /core-concepts/collections /en/guides/content-collections/ diff --git a/src/content/docs/en/reference/integrations-reference.mdx b/src/content/docs/en/reference/integrations-reference.mdx index bd2b87e504452..930d45eedc9cd 100644 --- a/src/content/docs/en/reference/integrations-reference.mdx +++ b/src/content/docs/en/reference/integrations-reference.mdx @@ -194,11 +194,11 @@ export default {
-**Type:** (renderer: AstroRenderer) => void;
+**Type:** (renderer: AstroRenderer) => void;
**Examples:** [`svelte`](https://github.com/withastro/astro/blob/main/packages/integrations/svelte/src/index.ts), [`react`](https://github.com/withastro/astro/blob/main/packages/integrations/react/src/index.ts), [`preact`](https://github.com/withastro/astro/blob/main/packages/integrations/preact/src/index.ts), [`vue`](https://github.com/withastro/astro/blob/main/packages/integrations/vue/src/index.ts), [`solid`](https://github.com/withastro/astro/blob/main/packages/integrations/solid/src/index.ts)
- -**Type:** `{ name: string; clientEntrypoint?: string | URL; serverEntrypoint: string | URL; }` -
- -Describes a [component framework renderer added by an integration](#addrenderer-option). - -#### `AstroRenderer.name` - -- -**Type:** `string` -
- -The name of the component framework renderer. - -#### `AstroRenderer.clientEntrypoint` - -- -**Type:** `string | URL` -
- -Defines the import path of the renderer that runs on the client whenever your component is used. - -#### `AstroRenderer.serverEntrypoint` - -- -**Type:** `string | URL` -
- -Defines the import path of the renderer that runs during server-side requests or static builds whenever your component is used. - ### `ClientDirectiveConfig`@@ -2028,152 +1989,6 @@ A description of how to render head content from this component, including wheth Determines whether the component contains the head content. -### `SSRLoadedRenderer` - -
- -**Type:** `{ name: string; clientEntrypoint?: string | URL; ssr: SSRLoadedRendererValue; }` -
- -Describes a renderer available for the server to use. This is a subset of [`AstroRenderer`](#astrorenderer) with additional properties. - -#### `SSRLoadedRenderer.ssr` - -- -**Type:** [`SSRLoadedRendererValue`](#ssrloadedrenderervalue) -
- -Defines the functions and configuration used by the server for this framework. - -### `SSRLoadedRendererValue` - -Contains the functions and configuration necessary to render components on the server from a specific UI framework. - -#### `SSRLoadedRendererValue.name` - -- -**Type:** `string` -
- -Specifies the name identifier for the renderer. - -#### `SSRLoadedRendererValue.check()` - -
-
-**Type:** `(Component: any, props: Record
-
-**Type:** `(Component: any, props: Record
-
-**Type:** `boolean`
-
-
-**Type:** `() => string`
-
- -**Type:** `{ displayName: string; hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only'; hydrateArgs?: any; componentUrl?: string; componentExport?: { value: string; namespace?: boolean }; astroStaticSlot: true; }` -
- -An object passed as the fourth argument to a renderer's [`check()`](#ssrloadedrenderervaluecheck) and [`renderToStaticMarkup()`](#ssrloadedrenderervaluerendertostaticmarkup) functions. Contains information about the component being rendered, including its hydration directive. - -#### `AstroComponentMetadata.displayName` - -- -**Type:** `string` -
- -The display name of the component, used for error messages and debugging. - -#### `AstroComponentMetadata.hydrate` - -- -**Type:** `'load' | 'idle' | 'visible' | 'media' | 'only' | undefined` -
- -The [client directive](/en/reference/directives-reference/#client-directives) used on the component, if any. When `undefined`, the component will not be hydrated on the client. - -Renderers can use this value to conditionally include client-side hydration state. For example, a renderer can skip serializing transfer state for components that will not be hydrated: - -```ts -async function renderToStaticMarkup(Component, props, children, metadata) { - const willHydrate = !!metadata?.hydrate; - // Skip serializing hydration state if the component won't be hydrated - return render(Component, props, { includeTransferState: willHydrate }); -} -``` - -#### `AstroComponentMetadata.hydrateArgs` - -- -**Type:** `any` -
- -Additional arguments for the hydration directive. For example, the value of `client:media="(max-width: 768px)"` would be `"(max-width: 768px)"`. For `client:only="react"`, the value would be `"react"`. - -#### `AstroComponentMetadata.componentUrl` - -- -**Type:** `string | undefined` -
- -The URL of the component's source file. - -#### `AstroComponentMetadata.componentExport` - -- -**Type:** `{ value: string; namespace?: boolean } | undefined` -
- -Information about the component's export. The `value` property is the name of the export (e.g. `"default"` for default exports). - -#### `AstroComponentMetadata.astroStaticSlot` - -- -**Type:** `true` -
- -Always `true`. Indicates that Astro supports the static slot optimization for this component. Renderers that set [`supportsAstroStaticSlot`](#ssrloadedrenderervaluesupportsastrostaticslot) to `true` can use this in combination with [`hydrate`](#astrocomponentmetadatahydrate) to determine how to render slots. - ### `SSRManifest` An object containing build configuration and project metadata that the server adapters use at runtime to serve on-demand rendered pages. @@ -2314,7 +2129,7 @@ Specifies the [configured prefix for Astro-generated asset links](/en/reference/
-**Type:** SSRLoadedRenderer[]
+**Type:** SSRLoadedRenderer[]
+ +**Type:** `{ displayName: string; hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only'; hydrateArgs?: any; componentUrl?: string; componentExport?: { value: string; namespace?: boolean }; astroStaticSlot: true; }` +
+ +An object passed as the fourth argument to a renderer's [`check()`](#ssrloadedrenderervaluecheck) and [`renderToStaticMarkup()`](#ssrloadedrenderervaluerendertostaticmarkup) functions. Contains information about the component being rendered, including its hydration directive. + +#### `AstroComponentMetadata.displayName` + ++ +**Type:** `string` +
+ +Defines the component name Astro uses in diagnostics and error messages. + +#### `AstroComponentMetadata.hydrate` + ++ +**Type:** `'load' | 'idle' | 'visible' | 'media' | 'only' | undefined` +
+ +Defines the [client directive](/en/reference/directives-reference/#client-directives) used on the component, if any. When `undefined`, the component will not be hydrated on the client. + +Renderers can use this value to conditionally include client-side hydration state. For example, a renderer can skip serializing transfer state for components that will not be hydrated: + +```ts +async function renderToStaticMarkup(Component, props, children, metadata) { + const willHydrate = !!metadata?.hydrate; + // Skip serializing hydration state if the component won't be hydrated + return render(Component, props, { includeTransferState: willHydrate }); +} +``` + +#### `AstroComponentMetadata.hydrateArgs` + ++ +**Type:** `any` +
+ +Specifies the additional arguments passed to the hydration directive. For example, the value of `client:media="(max-width: 768px)"` would be `"(max-width: 768px)"`. For `client:only="react"`, the value would be `"react"`. + +#### `AstroComponentMetadata.componentUrl` + ++ +**Type:** `string` +
+ +Defines the URL of the component's source file. + +#### `AstroComponentMetadata.componentExport` + ++ +**Type:** `{ value: string; namespace?: boolean }` +
+ +Describes the component's export Astro will load on the client for hydrated components. + +##### `AstroComponentMetadata.componentExport.namespace` + ++ +**Type:** `boolean` +
+ +Indicates whether the export is a namespace export. + +##### `AstroComponentMetadata.componentExport.value` + ++ +**Type:** `string` +
+ +Indicates the name of the export (e.g. `"default"` for default exports). + +#### `AstroComponentMetadata.astroStaticSlot` + ++ +**Type:** `true` +
+ +Always `true`. Indicates that Astro supports the static slot optimization for this component. Renderers that set [`supportsAstroStaticSlot`](#ssrloadedrenderervaluesupportsastrostaticslot) to `true` can use this in combination with [`hydrate`](#astrocomponentmetadatahydrate) to determine how to render slots. + +### `AstroRenderer` + ++ +**Type:** `{ name: string; clientEntrypoint?: string | URL; serverEntrypoint: string | URL; }` +
+ +Describes a [renderer added by an integration](/en/reference/integrations-reference/#addrenderer-option). + +#### `AstroRenderer.name` + ++ +**Type:** `string` +
+ +Defines the unique renderer's public name. This is used in error messages, logs, and for custom `client:only` hints such as `+ +**Type:** `string | URL` +
+ +Defines the import path of the renderer that runs on the client whenever your component is used. + +#### `AstroRenderer.serverEntrypoint` + ++ +**Type:** `string | URL` +
+ +Defines the import path of the renderer that runs during server-side requests or static builds whenever your component is used. + +### `AsyncRendererComponentFn` + +
+
+**Type:** `(Component: any, props: any, slots: Record
+
+**Type:** `Pick
+ +**Type:** [`SSRLoadedRendererValue`](#ssrloadedrenderervalue) +
+ +Defines the functions and configuration used by the server for this framework. + +### `SSRLoadedRendererValue` + +
+
+**Type:** `{ name?: string; check: AsyncRendererComponentFn
+ +**Type:** `string` +
+ +Defines the renderer name when the server renderer needs to carry its own name. When not provided, Astro will reuse the name defined in [`AstroRenderer`](#astrorenderer). + +#### `SSRLoadedRendererValue.check()` + +
+
+**Type:** `AsyncRendererComponentFn
+
+**Type:** `AsyncRendererComponentFn<{ html: string; attrs?: Record
+
+**Type:** `boolean`
+
+
+**Type:** `() => string`
+