You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0048-container-api.md
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,7 @@ but eventually each route must be rendered using the same data, which are:
82
82
-`AstroContainer::create`: creates a new instance of the container.
83
83
-`AstroContainer.renderToString`: renders a component and return a string.
84
84
-`AstroContainer.renderToResponse`: renders a component and returns the `Response` emitted by the rendering phase.
85
+
-`AstroContainer.addServerRenderer`: to programmatically store a renderer inside the container.
85
86
86
87
### `create` function
87
88
@@ -126,14 +127,47 @@ It will be possible to tweak the container APIs with options and such. The `.cre
126
127
```ts
127
128
typeAstroContainerOptions= {
128
129
streaming:boolean;
129
-
renderers:AstroRenderer[];
130
+
renderers:AddServerRenderer[];
130
131
astroConfig:AstroUserConfig;
131
132
}
132
133
```
133
134
134
135
The `astroConfig` object is literally the same object exposed by the `defineConfig`, inside the `astro.config.mjs` file. This very configuration
135
136
will go under the same schema validation that Astro uses internally. This means that an invalid schema will result in an error of the `create` function.
136
137
138
+
#### Add a renderer
139
+
140
+
Adding a renderer can be done manually or automatically.
141
+
142
+
The automatic way is meant for static applications, or cases where the container isn't called at runtime. The renderers maintained by the Astro org will expose
143
+
a method called `getContainerRenderer` that will return the correct information that will tell the container **how to import the renderer**. The importing of the renderer is done via a function called `loadRenderers`, exported by a new virtual module called `astro:container`:
The manual way is meant for on-demand applications, or cases where the container is called at runtime or inside other "shells" (PHP, Ruby, Java, etc.).
159
+
The developer is in charge of **importing** the server renderer and store it inside the container via `AstroContainer.addServerRenderer`:
160
+
161
+
The renderers maintained by the Astro org will ship proper types for importing server renderers.
0 commit comments