For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Book a demoLog inStart for free
  • Getting started
    • Overview
    • How it works
    • Quickstart
    • Project structure
    • Customer showcase
    • Changelog
  • Configuration
    • Overview
    • Site-level settings
    • Page-level settings
  • Writing content
    • Markdown basics
    • Rich media in Markdown
    • Fern Editor
    • Reusable snippets
  • AI features
    • Overview
    • Fern Writer
    • AI-generated examples
    • Markdown access
      • Overview
      • Customize LLM output
      • Agent directives
      • Analytics and integration
    • MCP server
    • API catalog discovery
      • Announcement banner
      • Embedded mode
      • Hiding content
      • Search
      • User feedback
      • Custom CSS & JS
      • CSS selectors reference
      • Custom React components
      • Header and footer
      • Global themes
  • Public API
    • GETJWT from Fern API key
    • GETAlgolia search credentials
    • GETCurrent user information
  • Fern Writer API
    • GETGet Fern Writer Install Link
Checking status...
SOC2Soc 2 Type II
© 2026 Fern • Birch Solutions, Inc., a Postman company

Documentation

SDKsDocsAsk FernCLI Reference

API Definitions

OpenAPIAsyncAPIOpenRPCgRPC

Resources

BlogSupportPricing

Company

Brand KitPrivacy PolicyTerms of Service
LogoLogo
Book a demoLog inStart for free
On this page
  • Custom components in MDX
  • Why not just use custom CSS and JS instead?
Customization

Custom React components

||View as Markdown|
Was this page helpful?
Edit this page
Previous

CSS selectors reference

Next

Header and footer

You can extend Fern’s built-in component library by adding your own custom React components. This allows you to create unique, interactive elements that match your documentation needs. Components are server-side rendered for better SEO and performance, with no layout shifts.

Merge uses a custom React component to compare feature coverage across integrations in an interactive matrix.

Defining a constant

Don’t use a React component to define a constant. Instead, consider using reusable snippets.

Custom components in MDX

1

Create a React component

Let’s start by creating a components folder where you can define your React components. Note that the React components can be defined in .ts, .tsx, .js or .mdx files.

components/CustomCard.tsx
1 export const CustomCard = ({ title, text, link, sparkle = false }) => {
2 return (
3 <a href={link} className="block p-6 rounded-lg border border-gray-200 hover:shadow-lg transition-shadow">
4 <h2 className="text-xl font-semibold mb-2">
5 {title} {sparkle && "✨"}
6 </h2>
7 <p className="text-gray-600">{text}</p>
8 </a>
9 );
10 };
2

Use the component in your docs

Once you’ve written the component, you can import it in your Markdown guides using either a relative path or the @/ prefix for an absolute path from your fern folder root:

guide.mdx
1// Absolute path from fern folder root
2import { CustomCard } from "../../../../components/CustomCard"
3
4// Or use a relative path
5import { CustomCard } from "../components/CustomCard"
6
7<CustomCard
8 title="MyTitle"
9 text="Hello"
10 href="https://github.com/fern-api/fern/tree/main/generators/python"
11/>

The @/ prefix resolves to the root of your fern folder, so @/components/CustomCard refers to fern/components/CustomCard. This is useful for nested MDX files where relative paths would be cumbersome (e.g., ../../../components/CustomCard). Both import styles are automatically transformed to relative paths at publish time.

3

Specify your components directory in docs.yml

Add your components directory to docs.yml so that the Fern CLI can scan your components directory and upload them to the server.

docs.yml
1experimental:
2 mdx-components:
3 - ./components

Why not just use custom CSS and JS instead?

While you can bundle React components as custom JavaScript, using Fern’s built-in React component support provides several key advantages:

No layout shifts or flashes

When adding React components via custom JavaScript, you can’t control when components are rendered relative to the rest of the page content. This often leads to glitchy behavior where components flash or jump as they load asynchronously after the main content.

Faster page load

Custom JavaScript bundles typically include their own copy of the React library, which:

  • Increases page load time by duplicating React code that’s already included
  • Reduces performance as multiple React instances run on the same page
  • Creates larger bundle sizes that users have to download
Improved SEO

Custom React components are server-side rendered and fully indexable by search engines, while components added via custom JavaScript aren’t server-side rendered and can’t be indexed.