@astrojs/react
7.1.9 · 13 Nov 2026MIT4M / weekRepositoryHomepagenpmAtom feed
109 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 3.x
3.6.1
30 Jul 2024- Breaking
BREAKING CHANGE to the experimental Actions API only. Install the latest
@astrojs/reactintegration as well if you're using React 19 features.Make
.safe()the default return value for actions. This means{ data, error }will be returned when calling an action directly. If you prefer to get the data while allowing errors to throw, chain the.orThrow()modifier.import { actions } from 'astro:actions'; // Before const { data, error } = await actions.like.safe(); // After const { data, error } = await actions.like(); // Before const newLikes = await actions.like(); // After const newLikes = await actions.like.orThrow(); - Breaking
BREAKING CHANGE to the experimental Actions API only. Install the latest
@astrojs/reactintegration as well if you're using React 19 features.Updates the Astro Actions fallback to support
action={actions.name}instead of usinggetActionProps().This will submit a form to the server in zero-JS scenarios using a search parameter:--- import { actions } from 'astro:actions'; --- <form action={actions.logOut}> <!--output: action="?_astroAction=logOut"--> <button>Log Out</button> </form>You may also construct form action URLs using string concatenation, or by using the
URL()constructor, with the an action's.queryStringproperty:--- import { actions } from 'astro:actions'; const confirmationUrl = new URL('/confirmation', Astro.url); confirmationUrl.search = actions.queryString; --- <form method="POST" action={confirmationUrl.pathname}> <button>Submit</button> </form>
3.6.0
17 Jun 2024Adds a new function called
addServerRendererto 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:
import type { APIRoute } from 'astro'; import { experimental_AstroContainer } from 'astro/container'; 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'; // MDX runtime is contained inside the Astro core import mdxRenderer from 'astro/jsx/server.js'; // In case you need to import a custom renderer import customRenderer from '../renderers/customRenderer.js'; export const GET: APIRoute = async (ctx) => { const container = await experimental_AstroContainer.create(); container.addServerRenderer({ renderer: reactRenderer }); container.addServerRenderer({ renderer: vueRenderer }); container.addServerRenderer({ renderer: customRenderer }); // You can pass a custom name too container.addServerRenderer({ name: 'customRenderer', renderer: customRenderer, }); const vueComponent = await container.renderToString(VueComponent); return await container.renderToResponse(Component); };
3.5.0
6 Jun 2024The integration now exposes a function called
getContainerRenderer, that can be used inside the Container APIs to load the relative renderer.import { experimental_AstroContainer as AstroContainer } from 'astro/container'; import ReactWrapper from '../src/components/ReactWrapper.astro'; import { loadRenderers } from 'astro:container'; import { getContainerRenderer } from '@astrojs/react'; test('ReactWrapper with react renderer', async () => { const renderers = await loadRenderers([getContainerRenderer()]); const container = await AstroContainer.create({ renderers, }); const result = await container.renderToString(ReactWrapper); expect(result).toContain('Counter'); expect(result).toContain('Count: <!-- -->5'); });
3.4.0
23 May 2024Adds two new functions
experimental_getActionState()andexperimental_withState()to support the React 19useActionState()hook when using Astro Actions. This introduces progressive enhancement when calling an Action with thewithState()utility.This example calls a
likeaction that accepts apostIdand returns the number of likes. Pass this action to theexperimental_withState()function to apply progressive enhancement info, and apply touseActionState()to track the result:import { actions } from 'astro:actions'; import { experimental_withState } from '@astrojs/react/actions'; export function Like({ postId }: { postId: string }) { const [state, action, pending] = useActionState( experimental_withState(actions.like), 0 // initial likes ); return ( <form action={action}> <input type="hidden" name="postId" value={postId} /> <button disabled={pending}>{state} ❤️</button> </form> ); }You can also access the state stored by
useActionState()from your actionhandler. Callexperimental_getActionState()with the API context, and optionally apply a type to the result:import { defineAction, z } from 'astro:actions'; import { experimental_getActionState } from '@astrojs/react/actions'; export const server = { like: defineAction({ input: z.object({ postId: z.string(), }), handler: async ({ postId }, ctx) => { const currentLikes = experimental_getActionState<number>(ctx); // write to database return currentLikes + 1; }, }), };
3.3.4
9 May 2024Fixes incorrect
peerDependenciesfor@types/reactand@types/react-dom
3.3.3
9 May 2024Updates package to support React 19 beta
3.3.2
2 May 2024- Removed
Removes using deprecated
ReactDOMServer.renderToStaticNodeStreamAPI
3.3.1
23 Apr 2024Fix Redoc usage in React integration
3.3.0
11 Apr 2024- Deprecated
Deprecate support for versions of Node.js older than
v18.17.1for Node.js 18, older thanv20.0.3for Node.js 20, and the complete Node.js v19 release line.This change is in line with Astro's Node.js support policy.
3.2.0
9 Apr 2024Expose Babel config for @astro/react.
3.1.1
2 Apr 2024Mark @material-tailwind/react as noExternal
3.1.0
11 Mar 2024Changes the default behavior of
transition:persistto update the props of persisted islands upon navigation. Also adds a new view transitions optiontransition:persist-props(default:false) to prevent props from updating as needed.Islands which have the
transition:persistproperty to keep their state when using the<ViewTransitions />router will now have their props updated upon navigation. This is useful in cases where the component relies on page-specific props, such as the current page title, which should update upon navigation.For example, the component below is set to persist across navigation. This component receives a
productsprops and might have some internal state, such as which filters are applied:<ProductListing transition:persist products={products} />Upon navigation, this component persists, but the desired
productsmight change, for example if you are visiting a category of products, or you are performing a search.Previously the props would not change on navigation, and your island would have to handle updating them externally, such as with API calls.
With this change the props are now updated, while still preserving state.
You can override this new default behavior on a per-component basis using
transition:persist-props=trueto persist both props and state during navigation:<ProductListing transition:persist-props="true" products={products} />
3.0.10
7 Feb 2024Fixes an issue where passing void elements (img, etc..) did not work with the
experimentalReactChildrenoption enabled
3.0.9
27 Dec 2023Improves compatability with the Qwik adapter
Updates README
3.0.8
20 Dec 2023Prevents unsupported
forwardRefcomponents created by Preact from being rendered by ReactUpgrades vite to latest
3.0.7
5 Dec 2023Adds Vite 5 support. There are no breaking changes from Astro. Check the Vite migration guide for details of the breaking changes from Vite instead.
3.0.6
21 Nov 2023Fixes an issue where slotting self-closing elements (img, br, hr) into react components with
experimentalReactChildrenenabled led to an error.
3.0.5
16 Nov 2023Uses
node:streamduring server rendering for compatibility with Cloudflare
3.0.4
24 Oct 2023Fixes client hydration in islands when using experimentalReactChildren
3.0.3
5 Oct 2023Add provenance statement when publishing the library from CI
3.0.2
8 Sep 2023Update
experimentalReactChildrenbehavior to support void tags
3.0.1
6 Sep 2023Fix React dev mode using a base
3.0.0
30 Aug 2023- Breaking
Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023.
- Breaking
Astro 3.0 Release Candidate
- Breaking
Support for React Refresh
The React integration now fully supports React Refresh and is backed by
@vitejs/plugin-react.Also included in this change are new
includeandexcludeconfig options. Use these if you want to use React alongside another JSX framework; include specifies files to be compiled for React andexcludedoes the opposite.
Major Changes
- Breaking
Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023.
- Breaking
Astro 3.0 Release Candidate
- Breaking
Support for React Refresh
The React integration now fully supports React Refresh and is backed by
@vitejs/plugin-react.Also included in this change are new
includeandexcludeconfig options. Use these if you want to use React alongside another JSX framework; include specifies files to be compiled for React andexcludedoes the opposite.
Patch Changes
Publish missing
vnode-children.jsfileAutomatically unmount islands when
astro:unmountis fired
- 2.x
2.3.2
18 Aug 2023Fix missing package file regression
2.3.1
18 Aug 2023Reading the note…
2.3.0
18 Aug 2023Reading the note…
2.2.2
15 Aug 2023Reading the note…
2.2.1
30 May 2023Reading the note…
2.2.0
18 May 2023Reading the note…
2.1.3
4 May 2023Reading the note…
2.1.2
1 May 2023Reading the note…
2.1.1
31 Mar 2023Reading the note…
2.1.0
7 Mar 2023Reading the note…
2.0.2
30 Jan 2023Reading the note…
2.0.1
26 Jan 2023Reading the note…
2.0.0
24 Jan 2023Reading the note…
- 1.x
1.2.2
28 Oct 2022Reading the note…
1.2.1
18 Oct 2022Reading the note…
1.2.0
10 Oct 2022Reading the note…
1.1.4
20 Sep 2022Reading the note…
1.1.3
14 Sep 2022Reading the note…
1.1.2
9 Sep 2022Reading the note…
1.1.1
30 Aug 2022Reading the note…
1.1.0
26 Aug 2022Reading the note…
1.0.0
9 Aug 2022Reading the note…
- 0.4.x
0.4.3
6 Aug 2022Reading the note…
0.4.2
19 Jul 2022Reading the note…
0.4.1
14 Jul 2022Reading the note…
0.4.0
13 Jul 2022Reading the note…
- 0.3.x
0.3.1
12 Jul 2022Reading the note…
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.