React Component Support
Mintlify MDX supports embedding custom React components directly in your documentation:- Import components from the
snippetsfolder - Use React hooks (useState, useEffect, etc.)
- Create interactive demos, calculators, and visualizations
- Build reusable component libraries
snippets/ColorPicker.jsx
Using the Component
React components must be placed in the
snippets folder and exported as named exports. You cannot import components from arbitrary MDX files.Preventing the Double Flash
Mintlify pages render server-side first, then hydrate on the client. React components that modify layout or inject dynamic content cause a double flash: the server-rendered markup appears, disappears during hydration, then re-renders with client state. This creates a jarring flicker. The fix: render your component invisible on mount, then fade it in after hydration completes.- Pattern
- With Slide Animation
- Page Modes
- Custom Mode Landing Pages
Every client-side React component should follow this three-part pattern:
- State gate:
useState(false)tracks whether the component has mounted - Mount trigger:
useEffect(() => set(true), [])fires once after hydration - Opacity transition: the wrapper starts at
opacity: 0and transitions to1
snippets/MyComponent.jsx
Loading External Scripts
Mintlify doesn’t support<script> tags directly in MDX. Instead, use Mintlify’s built-in load() function to fetch external libraries at runtime. Chain multiple load() calls with .then() to guarantee dependency order, and guard your initialization against Mintlify’s hydration timing.
snippets/AnimatedSection.jsx
- Sequential loading: Chain
.then()calls so dependent libraries (like ScrollTrigger) load after their prerequisites (GSAP core) - Hydration-safe init: Check
document.readyStatefirst, then also set asetTimeoutfallback — Mintlify’s hydration can delay DOM readiness beyond the browser’sloadevent - Idempotency guard: Before the timeout fires, check whether initialization already ran (e.g.,
ScrollTrigger.getAll().length === 0) to avoid double-initializing