#auto import components
1 messages · Page 1 of 1 (latest)
Hi @stray ingot. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Astro and Starlight don’t provide a built-in “auto-import” for components in MDX. You must import components at the top of each .mdx file before using them, e.g.:
import { Card } from '@astrojs/starlight/components';
<Card title="Check this out">Content</Card>
This is the documented usage for components in MDX (install @astrojs/mdx, then import and use components) (Using components in MDX; Starlight components usage).
If you need MDX-wide remapping of HTML elements to custom components (not auto-imports), you can export a components map from the MDX file and pass it through when importing MDX, or define it within the MDX file itself (Custom components with imported MDX; Assigning custom components).
I’m sorry, but the knowledge sources don’t mention an official auto-import integration for MDX components. The Starlight docs show explicit imports per file, and the Astro MDX guide does the same.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@stray ingot Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@flat lake https://github.com/delucis/astro-auto-import is what I was looking for
Let me check the knowledge base for you again. One moment! :books:
I can’t confirm details about astro-auto-import from the provided knowledge sources. They don’t document an official auto-import feature for MDX; components are shown as explicitly imported in each .mdx file (Using components in MDX; Starlight: Using components).