Stateinik

Authoring in MDX

Published Jun 24, 20261 min readBeginner
301views

TL;DR

Why MDX

Plain Markdown is great for prose but can't express callouts, step lists or comparison tables. MDX lets you drop in components exactly where you need them.

Whitelist

Only components on the sanitizer whitelist may appear in MDX. This keeps authored content safe to render.

Adding a block

tsx
// 1. Create the component, 2. register it in components/mdx-blocks/index.ts,
// 3. add its name to the sanitizer whitelist.
export function Highlight({ children }: { children: React.ReactNode }) {
  return <mark className="bg-accent-soft">{children}</mark>
}
Was this guide helpful?
Author
Ada Lovelace
Demo author

A placeholder author for the Stateinik demo. Replace with your own in the admin.

Topic
Welcome to Stateinik
Main article of the topic
Related articles

Related guides