In the modern world of web development, the headless CMS has become a cornerstone for flexible, scalable content management. It decouples your content from your presentation layer, giving you the freedom to build rich, immersive frontends with frameworks like React. But a common challenge arises: how do you manage content that's more than just text and images? How do you embed interactive, component-driven experiences directly from your CMS?
Traditionally, this has been a complex problem. Standard Markdown is limited, and while MDX (Markdown + JSX) offers a powerful solution, it's typically tied to a static build process. If you're fetching content dynamically from a CMS at runtime, you're usually out of luck.
Until now. Meet mdx.do, the service that brings dynamic MDX compilation to your headless workflow.
MDX is revolutionary. It lets you write JSX directly in your Markdown files, seamlessly blending static content with interactive React components. This is the essence of CONTENT AS CODE. You can import and render charts, interactive forms, or custom UI elements right alongside your paragraphs and headings.
The standard MDX workflow looks like this:
This works perfectly for content that's part of your codebase, like a blog or documentation pages. But what about content from a headless CMS, user-generated content, or content stored in a database? This content is fetched on-demand, long after your application has been built and deployed. The static build-time compilation model simply doesn't apply.
mdx.do fundamentally changes the game by offering Dynamic MDX Compilation as a Service. It decouples the compilation process from your build step and turns it into a simple, on-demand API call.
The concept is brilliantly simple:
There are no complex build steps to configure, no heavy dependencies to bundle in your client-side application. Just a pure, functional approach to dynamic content.
Using the mdx.do SDK is incredibly straightforward. Imagine you've just fetched an article from your headless CMS.
import { mdx } from '@do-sdk/mdx';
// This MDX string could come from your headless CMS API
const mdxContentFromCMS = `
---
title: Hello MDX!
author: '.do'
---
# This is a heading
And this is **Markdown** with an interactive <LiveComponent />!
`;
// Compile your MDX string into a renderable component
const { component, frontmatter } = await mdx.compile({
content: mdxContentFromCMS
});
// `component` can now be rendered in your React app.
// For example:
// <article>
// <h1>{frontmatter.title}</h1>
// <p>By: {frontmatter.author}</p>
// <MDXRenderer component={component} />
// </article>
// `frontmatter` contains your metadata.
// console.log(frontmatter) -> { title: 'Hello MDX!', author: '.do' }
In this example, mdx.do handles the heavy lifting of parsing the Markdown, processing the YAML frontmatter, and compiling the JSX into a functional component that your React application can render instantly.
Integrating mdx.do into your headless architecture offers several powerful advantages:
Q: What is MDX?
A: MDX is an authorable format that lets you seamlessly write JSX in your Markdown documents. It's a powerful way to embed interactive components directly within your content, transforming static documents into rich applications.
Q: How does mdx.do work?
A: mdx.do provides a simple API endpoint. You send an MDX string to the service, and it returns a compiled, ready-to-render React component, along with any frontmatter metadata. This offloads the compilation process from your application's build environment.
Q: Why use mdx.do instead of a local library?
A: Using mdx.do is ideal for dynamic content scenarios where you can't rely on a static build step. It's a perfect fit for user-generated content, CMS-driven pages, or any situation where you need to compile MDX on-demand without bloating your own infrastructure.
Q: What is frontmatter?
A: Frontmatter is metadata (like title, author, or tags) written in languages like YAML at the beginning of a Markdown or MDX file. mdx.do automatically parses this for you and returns it as a structured JSON object alongside your component.
Stop letting your build process dictate your content strategy. With mdx.do, you can finally unlock the full potential of your headless CMS and deliver the dynamic, component-driven experiences your users deserve.
Ready to transform your content workflow? Explore mdx.do and start compiling MDX on-demand today.