Skip to main content
Build interactive elements in your docs using React components and hooks directly in MDX files.

Inline components

Declare components directly in your MDX file:

Import components

Component files must be in the /snippets/ folder. Learn more about reusable snippets.
Nested imports are not supported. Import all referenced components directly into the parent MDX file.
Create a component file in snippets/:
/snippets/color-generator.jsx
Then import and use it:

Considerations

  • SEO: Search engines may not fully index client-rendered dynamic content.
  • Initial load: Visitors may see a flash before components render.
  • Accessibility: Ensure screen readers announce dynamic content changes.
  • Optimize dependency arrays: Only include necessary dependencies in useEffect.
  • Memoize expensive operations: Use useMemo or useCallback where appropriate.
  • Reduce re-renders: Break large components into smaller ones.
  • Lazy loading: Lazy load complex components to improve initial page load.