Packages

@astrojs/react

7.1.9 · 13 Nov 2026MIT4M / weekRepositoryHomepagenpmAtom feed

Your version

109 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.

  1. 3.x
  2. 3.6.1

    30 Jul 2024
    • Breaking

      BREAKING CHANGE to the experimental Actions API only. Install the latest @astrojs/react integration 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/react integration as well if you're using React 19 features.

      Updates the Astro Actions fallback to support action={actions.name} instead of using getActionProps(). 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 .queryString property:

      ---
      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. 3.6.0

    17 Jun 2024
    • 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:

      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);
      };
  4. 3.5.0

    6 Jun 2024
    • The 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');
      });
  5. 3.4.0

    23 May 2024
    • Adds two new functions experimental_getActionState() and experimental_withState() to support the React 19 useActionState() hook when using Astro Actions. This introduces progressive enhancement when calling an Action with the withState() utility.

      This example calls a like action that accepts a postId and returns the number of likes. Pass this action to the experimental_withState() function to apply progressive enhancement info, and apply to useActionState() 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 action handler. Call experimental_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;
          },
        }),
      };
  6. 3.3.4

    9 May 2024
  7. 3.3.3

    9 May 2024
    • Updates package to support React 19 beta

  8. 3.3.2

    2 May 2024
    • Removed

      Removes using deprecated ReactDOMServer.renderToStaticNodeStream API

  9. 3.3.1

    23 Apr 2024
    • Fix Redoc usage in React integration

  10. 3.3.0

    11 Apr 2024
    • Deprecated

      Deprecate support for versions of Node.js older than v18.17.1 for Node.js 18, older than v20.0.3 for Node.js 20, and the complete Node.js v19 release line.

      This change is in line with Astro's Node.js support policy.

  11. 3.2.0

    9 Apr 2024
    • Expose Babel config for @astro/react.

  12. 3.1.1

    2 Apr 2024
    • Mark @material-tailwind/react as noExternal

  13. 3.1.0

    11 Mar 2024
    • Changes the default behavior of transition:persist to update the props of persisted islands upon navigation. Also adds a new view transitions option transition:persist-props (default: false) to prevent props from updating as needed.

      Islands which have the transition:persist property 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 products props 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 products might 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=true to persist both props and state during navigation:

      <ProductListing transition:persist-props="true" products={products} />
  14. 3.0.10

    7 Feb 2024
    • Fixes an issue where passing void elements (img, etc..) did not work with the experimentalReactChildren option enabled

  15. 3.0.9

    27 Dec 2023
  16. 3.0.8

    20 Dec 2023
    • Prevents unsupported forwardRef components created by Preact from being rendered by React

    • Upgrades vite to latest

  17. 3.0.7

    5 Dec 2023
    • 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.

  18. 3.0.6

    21 Nov 2023
    • Fixes an issue where slotting self-closing elements (img, br, hr) into react components with experimentalReactChildren enabled led to an error.

  19. 3.0.5

    16 Nov 2023
    • Uses node:stream during server rendering for compatibility with Cloudflare

  20. 3.0.4

    24 Oct 2023
    • Fixes client hydration in islands when using experimentalReactChildren

  21. 3.0.3

    5 Oct 2023
    • Add provenance statement when publishing the library from CI

  22. 3.0.2

    8 Sep 2023
    • Update experimentalReactChildren behavior to support void tags

  23. 3.0.1

    6 Sep 2023
    • Fix React dev mode using a base

  24. 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 include and exclude config options. Use these if you want to use React alongside another JSX framework; include specifies files to be compiled for React and exclude does the opposite.

  25. 2.x
  26. 2.3.2

    18 Aug 2023
    • Fix missing package file regression

  27. 2.3.1

    18 Aug 2023

    Reading the note…

  28. 2.3.0

    18 Aug 2023

    Reading the note…

  29. 2.2.2

    15 Aug 2023

    Reading the note…

  30. 2.2.1

    30 May 2023

    Reading the note…

  31. 2.2.0

    18 May 2023

    Reading the note…

  32. 2.1.3

    4 May 2023

    Reading the note…

  33. 2.1.2

    1 May 2023

    Reading the note…

  34. 2.1.1

    31 Mar 2023

    Reading the note…

  35. 2.1.0

    7 Mar 2023

    Reading the note…

  36. 2.0.2

    30 Jan 2023

    Reading the note…

  37. 2.0.1

    26 Jan 2023

    Reading the note…

  38. 2.0.0

    24 Jan 2023

    Reading the note…

  39. 1.x
  40. 1.2.2

    28 Oct 2022

    Reading the note…

  41. 1.2.1

    18 Oct 2022

    Reading the note…

  42. 1.2.0

    10 Oct 2022

    Reading the note…

  43. 1.1.4

    20 Sep 2022

    Reading the note…

  44. 1.1.3

    14 Sep 2022

    Reading the note…

  45. 1.1.2

    9 Sep 2022

    Reading the note…

  46. 1.1.1

    30 Aug 2022

    Reading the note…

  47. 1.1.0

    26 Aug 2022

    Reading the note…

  48. 1.0.0

    9 Aug 2022

    Reading the note…

  49. 0.4.x
  50. 0.4.3

    6 Aug 2022

    Reading the note…

  51. 0.4.2

    19 Jul 2022

    Reading the note…

  52. 0.4.1

    14 Jul 2022

    Reading the note…

  53. 0.4.0

    13 Jul 2022

    Reading the note…

  54. 0.3.x
  55. 0.3.1

    12 Jul 2022

    Reading 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.