Skip to content

MDX Demo Post

This post showcases the power of MDX by combining Markdown with React components for rich, interactive content.

• 3 min read

MDX Demo Post

This is a demonstration of MDX functionality in your Astro blog! MDX allows you to use React components directly in your Markdown content.

What is MDX?

MDX is a powerful format that lets you write JSX directly in your Markdown files. This means you can:

  • Write content in Markdown (like this paragraph)
  • Use React components inline
  • Create interactive content
  • Build rich, engaging blog posts

Interactive Components

Here’s a simple interactive component:

Welcome to MDX!

This interactive block is rendered with React, hydrated on the client.

Want to defer hydration until the browser is idle? Just change the directive:

Welcome to MDX!

This interactive block is rendered with React, hydrated on the client.

Why two components?

Hydration directives make it easy to balance performance and interactivity. The first component hydrates immediately, while the second waits until the main thread is free.

Code Blocks Still Work

// You can still use code blocks normally
function Greeting({ name }: { name: string }) {
  return <h1>Hello, {name}!</h1>;
}

export default Greeting;

Styled Lists

  • Combine Markdown with React components

    Blend prose and interactivity seamlessly.

  • Enhance reading experience

    Expose reusable UI patterns directly inside content.

  • Ship faster

    Avoid bespoke HTML every time you need a callout or tip.

Custom Styling

You can style content with Tailwind classes:

Content patterns unlocked by MDX

Build once, reuse everywhere

Publish UI as Astro components and consume them like Markdown primitives.

Keep styling consistent

Every block inherits your Tailwind + daisyUI theme tokens.

Mix static + interactive

Hydrate only when needed with client directives.

Stay author-friendly

Writers use declarative components rather than raw HTML.

Conclusion

Attention banner for big news

Inline badges for quick emphasis

Meeting accessibility targets is

AA compliant and our performance budget is 95 Lighthouse. You can even wrap the badge in a link: Astro MDX guide .

Astro components inside MDX

You can seamlessly drop Astro components into MDX:

MDX + Astro

Slots, props, and your design tokens are all available. Build reusable callout components, tab sets, or anything else you like and consume them directly in content files.

Pass props into React islands

Tip: click a swatch to copy the hex value to your clipboard.

Monthly readers

48k

+12% vs last month

Newsletter signups

2.4k

+240 this week

Time on page

4m 12s

steady engagement

Hydrate on visibility

client:visible demo

This component hydrates only when you scroll it into view. The heartbeat updates every second once it is active.

Ticks
00
Last ping
1:14:25 AM

MDX opens up a whole new world of possibilities for blog content. You can now create rich, interactive posts that go beyond traditional Markdown while maintaining the simplicity and readability of Markdown syntax.

The best part? Your existing Markdown posts continue to work exactly as before!

Share Twitter LinkedIn
Thanks for reading.
← All posts