- Published on
How to Write MDX Pages
2 min read
- Authors
- Name
- Shovan Karna

Writing content with MDX (Markdown + JSX) combines the simplicity of Markdown with the flexibility of React components, enabling you to write interactive and dynamic content.
In this blog, you'll learn the basics of creating MDX pages and how to structure them for your projects.
What is MDX?
MDX stands for Markdown with JSX. It lets you write Markdown and embed React components directly into your content. This is particularly useful for creating blogs, documentation, or any site with rich, interactive content.
Why Use MDX?
Write Markdown and React Together
Combine the simplicity of Markdown for text with React for interactivity.Component Reusability
Use existing React components like buttons, code blocks, or custom widgets.Easy Integration
Works seamlessly with frameworks like Next.js, Gatsby, and others.
Writing Your First MDX Page
To create an MDX page, you need:
- An MDX file (e.g.,
my-first-blog.mdx). - A system to render MDX, such as Next.js with
@next/mdxor Gatsby withgatsby-plugin-mdx.
The Anatomy of an MDX Page
Here’s a basic structure:
---
title: 'Your Blog Title'
date: 'YYYY-MM-DD'
tags: ['tag1', 'tag2']
draft: false
summary: 'A short summary of the blog post.'
images: ['/path-to-feature-image.jpg']
authors: ['default']
---
# Welcome to Your First MDX Page
Write content using Markdown syntax. For example:
- Use `#` for headings.
- Write **bold** or *italic* text.
- Create lists:
- Bullet points
- Sub-points
## Embedding React Components
You can import and use React components inside an MDX file:
```jsx
import { Button } from '@/components/ui/button';
<Button onClick={() => alert('Hello!')}>Click Me</Button>