AI Workshop: learn to build apps with AI →
Integrations: Use React component in Astro

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


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 on the client side, unless you add client:load to them:

<Test client:load />

Lessons in this unit:

0: Introduction
1: Client-side routing and view transitions
2: View Transitions and Dark Mode
3: Adding React Framer Motion animations to an Astro site
4: ▶︎ Use React component in Astro
5: Passing Astro components to React components
6: htmx and Astro View Transitions
7: htmx forms and Astro View Transitions