Copyright 2025

The Valley of Code

A Flavio Copes project

Use React component in Astro
Use React component in Astro

First run npx astro add react

Then create components/Test.jsx

export default function Test(props) {
  return <p>test</p>
}

Now in a .astro component import it:

import Test from '../components/Test'

and in its “JSX” include it:

<Test />

Done!

One gotcha: React components are rendered server-side, not client side, unless you add client:load to them:

<Test client:load />


Join my AI Workshop !

The Web Development BOOTCAMP cohort starts in February 2026