Using React, Vue, or Svelte Components Inside Astro
This chapter builds directly on this site's own existing react1–react4, vue1, and svelte1 courses — it covers the integration boundary between Astro and those frameworks, not the frameworks' own syntax, which those courses already teach in full.
Adding a Framework Integration
npx astro add [framework] installs the needed packages and wires up astro.config.mjs automatically.
react(), vue(), and svelte() can all be active integrations in the same project simultaneously, with a single page importing a .jsx React component, a .vue Vue component, and a .svelte Svelte component side by side, each hydrating independently as its own island (Chapter 7).
Using a Framework Component
Props are passed as ordinary attributes, the same as any Astro component. Each framework's own file extension (.jsx/.tsx, .vue, .svelte) is imported directly — no wrapping needed.
A Real Constraint: Props Must Be Serializable
A Second Real Constraint: No Direct Cross-Framework Nesting
A React component cannot directly contain a Vue component as a JSX child, and vice versa — the two framework runtimes don't compose that way. Composition across frameworks happens at the Astro layer instead: an Astro component can wrap a framework island and use <slot /> (Chapter 4) to let Astro-level content — including other framework islands — surround it.
Both islands sit side by side inside Panel's own <slot /> — real, valid composition, achieved entirely at the Astro layer rather than one framework component containing the other directly.
react1–react4, vue1, and svelte1 courses already cover that ground in full.
Coding Challenges
Add the React integration, then use a React component in an Astro page passing a plain numeric prop (e.g. initialCount={5}), confirming the value is received correctly.
📄 View solutionDemonstrate the correct way to give a React island its own click handler — defined inside the component itself, not passed in as a function prop from Astro's frontmatter.
📄 View solutionBuild an Astro wrapper component with a <slot />, and use it to compose a React island and a Svelte (or Vue) island side by side inside it.
📄 View solutionChapter 8 Quick Reference
npx astro add [react|vue|svelte]— installs and configures a framework integration- Multiple integrations can coexist — a genuinely unusual trait among frameworks in this series
- Props are serialized — plain data survives; functions/class instances don't cross the boundary as props
- No direct cross-framework nesting — composition happens via an Astro wrapper's own
<slot /> - This chapter stops at the boundary — see
react1–react4/vue1/svelte1for the frameworks themselves - Next chapter: Data Fetching & API Endpoints