2025-11-17 (6 days ago)
so you want to write content for your next.js site but you're tired of writing plain html or dealing with complex cms setups. enter mdx - markdown on steroids.
mdx lets you write jsx directly in your markdown files. sounds simple, and it is. but it's surprisingly powerful.
you write this:
and it just works. react components living alongside your content.
first, install the dependencies:
update your next.config.ts:
create mdx-components.tsx at your project root:
that's it. you're ready.
it's just markdown. you don't need to learn a new syntax or deal with visual editors that break. write markdown like you always have.
components when you need them. most of the time, markdown is enough. but when you need something interactive or custom, just drop in a component.
type safety. since it's jsx, you get full typescript support. your ide knows what props your components expect.
no build headaches. next.js handles everything. no webpack configs, no babel plugins to debug.
here's how you might use it for a blog post:
your components get the full power of react - state, effects, whatever you need.
mdx-components.tsx is required. even if it's empty. next.js won't work without it.
file-based routing works. create app/blog/my-post/page.mdx and it becomes a route. nice.
dynamic imports. you can load mdx files dynamically based on url params. useful for blog systems.
in mdx-components.tsx, map html elements to your components:
now every heading, image, and link in your mdx files uses your custom components.
mdx gives you markdown's simplicity with react's power. perfect for content that's mostly text but occasionally needs something interactive.
no cms complexity. no weird templating languages. just markdown and react.
and in next.js 16, it works out of the box with app router, server components, and everything else.
honestly, it's kind of perfect for blogs and documentation sites.