Skip to content

Commit

Permalink
update changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jun 13, 2024
1 parent f5d08a7 commit 3d87d08
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions .changeset/dull-carpets-breathe.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
---
'@astrojs/react': minor
'astro': patch
---

Exposes a `renderer` object from `@astrojs/react/server.js` and `@astrojs/react/server17.js`. This is useful when using the Container API for on-demand pages:
Adds a new function called `addServerRenderer` to the Container API. Use this function to manually store renderers inside the instance of your container.

This new function should be preferred when using the Container API in environments like on-demand pages:

```ts
import type {APIRoute, SSRLoadedRenderer} from "astro";
import type {APIRoute} from "astro";
import { experimental_AstroContainer } from "astro/container";
import { renderer } from '@astrojs/react/server.js';
import Component from "../components/button.jsx"
import reactRenderer from '@astrojs/react/server.js';
import vueRenderer from '@astrojs/vue/server.js';
import ReactComponent from "../components/button.jsx"
import VueComponent from "../components/button.vue"

export const GET: APIRoute = async (ctx) => {
const renderers: SSRLoadedRenderer[] = [renderer];
const container = await experimental_AstroContainer.create({
renderers
});
const container = await experimental_AstroContainer.create();
container.addServerRenderer("@astrojs/react", reactRenderer);
container.addServerRenderer("@astrojs/vue", vueRenderer);
const vueComponent = await container.renderToString(VueComponent)
return await container.renderToResponse(Component);
}
```

0 comments on commit 3d87d08

Please sign in to comment.