#Can I import Astro components inside a JSX component?
2 messages · Page 1 of 1 (latest)
No, you cannot directly import Astro components inside a JSX component. According to the Astro documentation (https://docs.astro.build/en/guides/framework-components/#can-i-use-astro-components-inside-my-framework-components), any UI framework component, including JSX, becomes an "island" of that framework. These components must be written entirely as valid code for that framework, using only its own imports and packages. Therefore, you cannot import .astro components in a UI framework component such as .jsx.
However, you can use the Astro <slot /> pattern to pass static content generated by Astro components as children to your framework components inside an .astro component. Here's an example:
---import MyReactComponent from '../components/MyReactComponent.jsx';
import MyAstroComponent from '../components/MyAstroComponent.astro';---
<MyReactComponent>
<MyAstroComponent slot="name" />
</MyReactComponent>