Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
47 KiB
@astrojs/react
4.4.2
Patch Changes
-
#14715
3d55c5dThanks @ascorbic! - Adds support for client hydration ingetContainerRenderer()The
getContainerRenderer()function is exported by Astro framework integrations to simplify the process of rendering framework components when using the experimental Container API inside a Vite or Vitest environment. This update adds the client hydration entrypoint to the returned object, enabling client-side interactivity for components rendered using this function. Previously this required users to manually callcontainer.addClientRenderer()with the appropriate client renderer entrypoint.See the
container-with-vitestdemo for a usage example, and the Container API documentation for more information on using framework components with the experimental Container API.
4.4.1
Patch Changes
- #14621
e3175d9Thanks @GameRoMan! - Updatesviteversion to fix CVE
4.4.0
Minor Changes
-
#14386
f75f446Thanks @yanthomasdev! - Stabilizes the formerly experimentalgetActionState()andwithState()functions introduced in@astrojs/reactv3.4.0 used to integrate Astro Actions with React 19'suseActionState()hook.This example calls a
likeaction that accepts apostIdand returns the number of likes. Pass this action to thewithState()function to apply progressive enhancement info, and apply touseActionState()to track the result:import { actions } from 'astro:actions'; import { withState } from '@astrojs/react/actions'; import { useActionState } from 'react'; export function Like({ postId }: { postId: string }) { const [state, action, pending] = useActionState( 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 action handler. CallgetActionState()with the API context, and optionally apply a type to the result:import { defineAction } from 'astro:actions'; import { z } from 'astro:schema'; import { getActionState } from '@astrojs/react/actions'; export const server = { like: defineAction({ input: z.object({ postId: z.string(), }), handler: async ({ postId }, ctx) => { const currentLikes = getActionState<number>(ctx); // write to database return currentLikes + 1; }, }), };If you were previously using this experimental feature, you will need to update your code to use the new stable exports:
// src/components/Form.jsx import { actions } from 'astro:actions'; -import { experimental_withState } from '@astrojs/react/actions'; +import { withState } from '@astrojs/react/actions'; import { useActionState } from "react";// src/actions/index.ts import { defineAction, type SafeResult } from 'astro:actions'; import { z } from 'astro:schema'; -import { experimental_getActionState } from '@astrojs/react/actions'; +import { getActionState } from '@astrojs/react/actions';
4.3.1
Patch Changes
- #14326
c24a8f4Thanks @jsparkdev! - Updatesviteversion to fix CVE
4.3.0
Minor Changes
-
#13809
3c3b492Thanks @ascorbic! - Increases minimum Node.js version to 18.20.8Node.js 18 has now reached end-of-life and should not be used. For now, Astro will continue to support Node.js 18.20.8, which is the final LTS release of Node.js 18, as well as Node.js 20 and Node.js 22 or later. We will drop support for Node.js 18 in a future release, so we recommend upgrading to Node.js 22 as soon as possible. See Astro's Node.js support policy for more details.
⚠️ Important note for users of Cloudflare Pages: The current build image for Cloudflare Pages uses Node.js 18.17.1 by default, which is no longer supported by Astro. If you are using Cloudflare Pages you should override the default Node.js version to Node.js 22. This does not affect users of Cloudflare Workers, which uses Node.js 22 by default.
4.2.7
Patch Changes
- #13731
c3e80c2Thanks @jsparkdev! - update vite to latest version for fixing CVE
4.2.6
Patch Changes
- #13720
e1cd1aeThanks @florian-lefebvre! - Fixes SSR renderer type
4.2.5
Patch Changes
- #13663
a19a185Thanks @florian-lefebvre! - Improves type-safety of renderers
4.2.4
Patch Changes
-
#13596
3752519Thanks @jsparkdev! - update vite to latest version to fix CVE -
#13547
360cb91Thanks @jsparkdev! - Updates vite to the latest version
4.2.3
Patch Changes
- #13526
ff9d69eThanks @jsparkdev! - updateviteto the latest version
4.2.2
Patch Changes
- #13505
a98ae5bThanks @ematipico! - Updates the dependencyviteto the latest.
4.2.1
Patch Changes
- #13323
80926faThanks @ematipico! - Updatesesbuildandviteto the latest to avoid false positives audits warnings caused byesbuild.
4.2.0
Minor Changes
-
#13036
3c90d8fThanks @artmsilva! - Adds experimental support for disabling streamingThis is useful to support libraries that are not compatible with streaming such as some CSS-in-JS libraries. To disable streaming for all React components in your project, set
experimentalDisableStreaming: trueas a configuration option for@astrojs/react:// astro.config.mjs import { defineConfig } from 'astro/config'; import react from '@astrojs/react'; export default defineConfig({ integrations: [ react({ + experimentalDisableStreaming: true, }), ], });
4.1.6
Patch Changes
-
#12996
80c6801Thanks @bluwy! - Removes hardcodedssr.external: ['react-dom/server', 'react-dom/client']config that causes issues with adapters that bundle all dependencies (e.g. Cloudflare). These externals should already be inferred by default by Vite when deploying to a server environment.
4.1.5
Patch Changes
- #12887
ea603aeThanks @louisescher! - Adds a warning message when multiple JSX-based UI frameworks are being used without either theincludeorexcludeproperty being set on the integration.
4.1.4
Patch Changes
- #12923
c7642fbThanks @bluwy! - Removes react-specific entrypoints inoptimizeDeps.includeand rely on@vitejs/plugin-reactto add
4.1.3
Patch Changes
4.1.2
Patch Changes
4.1.1
Patch Changes
4.1.0
Minor Changes
- #12678
97c9265Thanks @bskimball! - Add React 19 stable to peer dependencies
4.0.0
Major Changes
Minor Changes
-
#12510
14feaf3Thanks @bholmesdev! - Changes the generated URL query param from_astroActionto_actionwhen submitting a form using Actions. This avoids leaking the framework name into the URL bar, which may be considered a security issue.
4.0.0-beta.2
Major Changes
Minor Changes
3.7.0-beta.1
Minor Changes
- #12510
14feaf3Thanks @bholmesdev! - Changes the generated URL query param from_astroActionto_actionwhen submitting a form using Actions. This avoids leaking the framework name into the URL bar, which may be considered a security issue.
3.6.3
Patch Changes
- #12481
8a46e80Thanks @marbrex! - Resolvevitepeer dependency problem for strict package managers like Yarn in PnP mode.
3.6.2
Patch Changes
- #11624
7adb350Thanks @bluwy! - Prevents throwing errors when checking if a component is a React component in runtime
3.6.1
Patch Changes
-
#11571
1c3265aThanks @bholmesdev! - 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();Migration
To migrate your existing action calls:
- Remove
.safefrom existing safe action calls - Add
.orThrowto existing unsafe action calls
- Remove
-
#11570
84189b6Thanks @bholmesdev! - 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>Migration
getActionProps()is now deprecated. To use the new fallback pattern, remove thegetActionProps()input from your form and pass your action function to the formactionattribute:--- import { actions, - getActionProps, } from 'astro:actions'; --- + <form method="POST" action={actions.logOut}> - <form method="POST"> - <input {...getActionProps(actions.logOut)} /> <button>Log Out</button> </form>
3.6.0
Minor Changes
-
#11234
4385bf7Thanks @ematipico! - Adds a new function calledaddServerRendererto 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
Minor Changes
-
#11144
803dd80Thanks @ematipico! - The integration now exposes a function calledgetContainerRenderer, 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
Minor Changes
-
#11071
8ca7c73Thanks @bholmesdev! - Adds two new functionsexperimental_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
Patch Changes
- #10986
4d16381Thanks @emish89! - Fixes incorrectpeerDependenciesfor@types/reactand@types/react-dom
3.3.3
Patch Changes
3.3.2
Patch Changes
- #10893
fd7a9edThanks @Angrigo! - Removes using deprecatedReactDOMServer.renderToStaticNodeStreamAPI
3.3.1
Patch Changes
- #10855
f6bddd3Thanks @lamATnginx! - Fix Redoc usage in React integration
3.3.0
Minor Changes
-
#10689
683d51a5eecafbbfbfed3910a3f1fbf0b3531b99Thanks @ematipico! - Deprecate support for versions of Node.js older thanv18.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
Minor Changes
- #10675
14f1d49a10541fecc4c10def8a094322442ccf23Thanks @fightingcat! - Expose Babel config for @astro/react.
3.1.1
Patch Changes
- #10654
195f51f82a44df32be73865949aabee0d46ffe61Thanks @matthewp! - Mark @material-tailwind/react as noExternal
3.1.0
Minor Changes
-
#10136
9cd84bd19b92fb43ae48809f575ee12ebd43ea8fThanks @matthewp! - Changes the default behavior oftransition: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
Patch Changes
- #9849
20ca3154fb37049cbcd51b06d9fa2ef25ac25a36Thanks @StandardGage! - Fixes an issue where passing void elements (img, etc..) did not work with theexperimentalReactChildrenoption enabled
3.0.9
Patch Changes
-
#9482
72b26daf694b213918f02d0fcbf90ab5b7ebc31fThanks @natemoo-re! - Improves compatibility with the Qwik adapter -
#9479
1baf0b0d3cbd0564954c2366a7278794fad6726eThanks @sarah11918! - Updates README
3.0.8
Patch Changes
-
#9403
7eb9fe8a7Thanks @knpwrs! - Prevents unsupportedforwardRefcomponents created by Preact from being rendered by React -
#9452
e83b5095fThanks @florian-lefebvre! - Upgrades vite to latest
3.0.7
Patch Changes
- #9122
1c48ed286Thanks @bluwy! - Adds 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.7-beta.0
Patch Changes
- #9122
1c48ed286Thanks @bluwy! - Adds 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
Patch Changes
- #9141
af43fb517Thanks @lilnasy! - Fixes an issue where slotting self-closing elements (img, br, hr) into react components withexperimentalReactChildrenenabled led to an error.
3.0.5
Patch Changes
- #8925
ac5633b8fThanks @brandonsdebt! - Usesnode:streamduring server rendering for compatibility with Cloudflare
3.0.4
Patch Changes
- #8898
4dee38711Thanks @matthewp! - Fixes client hydration in islands when using experimentalReactChildren
3.0.3
Patch Changes
- #8737
6f60da805Thanks @ematipico! - Add provenance statement when publishing the library from CI
3.0.2
Patch Changes
- #8455
85fe213feThanks @natemoo-re! - UpdateexperimentalReactChildrenbehavior to support void tags
3.0.1
Patch Changes
3.0.0
Major Changes
-
#8188
d0679a666Thanks @ematipico! - 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. -
#8179
6011d52d3Thanks @matthewp! - Astro 3.0 Release Candidate -
#7924
519a1c4e8Thanks @matthewp! - Support for React RefreshThe 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
-
#8228
4bd2fac8dThanks @bluwy! - Publish missingvnode-children.jsfile -
#8264
1f58a7a1bThanks @natemoo-re! - Automatically unmount islands whenastro:unmountis fired -
Updated dependencies [
d0679a666,2aa6d8ace,6011d52d3]:- @astrojs/internal-helpers@0.2.0
3.0.0-rc.6
Patch Changes
- #8264
1f58a7a1bThanks @natemoo-re! - Automatically unmount islands whenastro:unmountis fired
3.0.0-rc.5
Patch Changes
3.0.0-rc.4
Major Changes
Patch Changes
- Updated dependencies [
6011d52d3]:- @astrojs/internal-helpers@0.2.0-rc.2
3.0.0-beta.3
Minor Changes
-
#8082
16a3fdf93Thanks @matthewp! - Optionally parse React slots as React children.This adds a new configuration option for the React integration
experimentalReactChildren:export default { integrations: [ react({ experimentalReactChildren: true, }), ], };With this enabled, children passed to React from Astro components via the default slot are parsed as React components.
This enables better compatibility with certain React components which manipulate their children.
3.0.0-beta.2
Patch Changes
- Updated dependencies [
2aa6d8ace]:- @astrojs/internal-helpers@0.2.0-beta.1
3.0.0-beta.1
Major Changes
-
#7924
519a1c4e8Thanks @matthewp! - Support for React RefreshThe 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.
3.0.0-beta.0
Major Changes
1eae2e3f7Thanks @Princesseuh! - 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.
2.3.2
Patch Changes
2.3.1
Patch Changes
- #8137
8c0a4ed10Thanks @natemoo-re! - Fix missing export for newexperimentalReactChildrenoption
2.3.0
Minor Changes
-
#8082
16a3fdf93Thanks @matthewp! - Optionally parse React slots as React children.This adds a new configuration option for the React integration
experimentalReactChildren:export default { integrations: [ react({ experimentalReactChildren: true, }), ], };With this enabled, children passed to React from Astro components via the default slot are parsed as React components.
This enables better compatibility with certain React components which manipulate their children.
2.2.2
Patch Changes
- #8075
da517d405Thanks @SudoCat! - fix a bug where react identifierPrefix was set to null for client:only components causing React.useId to generate ids prefixed with null
2.2.1
Patch Changes
2.2.0
Minor Changes
-
#7093
3d525efc9Thanks @matthewp! - Prevent removal of nested slots within islandsThis change introduces a new flag that renderers can add called
supportsAstroStaticSlot. What this does is let Astro know that the render is sending<astro-static-slot>as placeholder values for static (non-hydrated) slots which Astro will then remove.This change is completely backwards compatible, but fixes bugs caused by combining ssr-only and client-side framework components like so:
<Component> <div> <Component client:load> <span>Nested</span> </Component> </div> </Component>
Patch Changes
2.1.3
Patch Changes
2.1.2
Patch Changes
2.1.1
Patch Changes
-
#6698
fc71c3f18Thanks @bholmesdev! - Update React README to reference the new React docs -
#6696
239b9a2fbThanks @matthewp! - Add use-immer as a noExternal module
2.1.0
Minor Changes
- #6213
afbbc4d5bThanks @Princesseuh! - Updated compilation settings to disable downlevelling for Node 14
2.0.2
Patch Changes
2.0.1
Patch Changes
2.0.0
Major Changes
- #5782
1f92d64eaThanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0
2.0.0-beta.0
See changes in 2.0.0-beta.0
Major Changes
- #5782
1f92d64eaThanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0
1.2.2
Patch Changes
- #5218
0b1241431Thanks @MoustaphaDev! - remove unnecessaryReactDOM.renderToStringoperation
1.2.1
Patch Changes
- #5095
ddfbef5acThanks @Princesseuh! - Add@types/packages as peerDependencies
1.2.0
Minor Changes
-
#5016
6efeaeb39Thanks @matthewp! - Add support for muiThis adds support for mui through configuration. Users will now not need to configure this library to get it to work.
1.1.4
Patch Changes
1.1.3
Patch Changes
1.1.2
Patch Changes
-
#4679
5986517b4Thanks @matthewp! - Prevent decoder from leaking -
#4667
9290b2414Thanks @Holben888! - Fix framework components on Vercel Edge
1.1.1
Patch Changes
1.1.0
Minor Changes
-
#4478
243525b15Thanks @matthewp! - Uses startTransition on React rootsThis prevents hydration from blocking the main thread when multiple islands are rendering at the same time.
1.1.0-next.0
Minor Changes
-
#4478
243525b15Thanks @matthewp! - Uses startTransition on React rootsThis prevents hydration from blocking the main thread when multiple islands are rendering at the same time.
1.0.0
Major Changes
-
04ad44563- > Astro v1.0 is out! Read the official announcement post.No breaking changes. This package is now officially stable and compatible with
astro@1.0.0!
0.4.3
Patch Changes
0.4.2
Patch Changes
0.4.1
Patch Changes
0.4.0
Minor Changes
- #3914
b48767985Thanks @ran-dall! - Rollback supportednode@16version. Minimum versions are nownode@14.20.0ornode@16.14.0.
0.3.1
Patch Changes
0.3.0
Minor Changes
- #3871
1cc5b7890Thanks @natemoo-re! - Update supportednodeversions. Minimum versions are nownode@14.20.0ornode@16.16.0.
0.2.1
Patch Changes
- #3854
b012ee55Thanks @bholmesdev! - [astro add] Support adapters and third party packages
0.2.0
Minor Changes
-
#3652
7373d61cThanks @natemoo-re! - Add support for passing named slots from.astro=> framework components.Each
slotis be passed as a top-level prop. For example:// From .astro <Component> <h2 slot="title">Hello world!</h2> <h2 slot="slot-with-dash">Dash</h2> <div>Default</div> </Component>; // For .jsx export default function Component({ title, slotWithDash, children }) { return ( <> <div id="title">{title}</div> <div id="slot-with-dash">{slotWithDash}</div> <div id="main">{children}</div> </> ); }
0.1.3
Patch Changes
- #3455
e9a77d86Thanks @natemoo-re! - Update client hydration to check forssrattribute. Requiresastro@^1.0.0-beta.36.
0.1.2
Patch Changes
- #3337
678c2b75Thanks @bholmesdev! - Fix: remove hydration failures on React v18 by exposing the "client" directive from Astro core.
0.1.1
Patch Changes
0.1.0
Minor Changes
e425f896Thanks @FredKSchott! - Add support for React v18
0.0.2
Patch Changes
- #2885
6b004363Thanks @bholmesdev! - Add README across Astro built-in integrations
- #2847
3b621f7aThanks @tony-sull! - Adds keywords to the official integrations to support discoverability on Astro's Integrations site
0.0.2-next.0
Patch Changes
- #2847
3b621f7aThanks @tony-sull! - Adds keywords to the official integrations to support discoverability on Astro's Integrations site