Skip to content
TurnIntoCMS

When MDX makes sense on a client Next.js site

By Yash Garg · · 6 min read

Raw MDX almost always hurts non-technical clients. Because MDX compiles directly into JavaScript, a single missing bracket or unclosed tag causes a build failure that halts deployment or crashes the site. Next.js supports both local and remote MDX content inside your application.

When clients need to adjust pricing tables, polish marketing copy, or swap out team headshots, handing them raw markup files turns developers into syntax gatekeepers. Non-technical editors should never have to debug compilation errors just to fix a spelling mistake. If you want to let clients edit Next.js sites without fielding frantic support requests, you must understand the risks of raw MDX and explore better alternatives for content handoff.

Why raw MDX is fragile in client hands

MDX is not standard Markdown. The remark-mdx parser is a unified remark plugin that enables MDX syntax extensions like JSX, export and import statements, and expressions. In standard Markdown, writing a stray angle bracket or a curly brace simply renders that character onto the page. In MDX, that same character is parsed as JSX syntax. An unescaped curly brace or an unclosed tag triggers a compilation failure that halts your entire Next.js build.

Evaluating untrusted MDX on a server also creates severe security concerns. The official MDX documentation notes that evaluating MDX compiles into JavaScript execution and cautions to only use evaluate when you trust your content because it evaluates JavaScript. When non-technical clients copy and paste text from Google Docs or rich email clients, invisible formatting characters and accidental symbols frequently trigger parsing errors.

These friction points prompted engineers at Stripe to build Markdoc. As noted in the Markdoc documentation FAQ, Markdoc was created to provide a format optimized for writing rather than programming to overcome the challenges of mixing code and content. Content files quickly accumulate logic, conditional statements, and component props that marketing teams cannot safely navigate.

Traditional markup formats treat rich text as raw strings that require brittle parsing at build time. When clients accidentally delete a closing tag or paste an unmatched quote, your automated deployment fails. Storing content as structured data or using visual tools prevents malformed markup from ever reaching your production branch, whereas raw MDX leaves your deployment vulnerable to every stray keystroke.

When MDX is actually the right tool

MDX excels when content authors are already comfortable working inside developer environments. If your content team consists of engineers, developer advocates, or technical writers working in code editors and opening Git pull requests, MDX is a practical choice for developer portals and technical documentation.

MDX is also valuable when content updates must deploy in lockstep with React components. In a content-heavy application where a new UI feature and its corresponding documentation need atomic versioning, storing content files in the same Git commit ensures that code and copy never fall out of sync.

The framework integration in modern Next.js setups is another strength. Next.js is unopinionated about how you organize and colocate your project files, allowing developers to store files outside the app directory or organize them into private folders. MDX makes sense for internal engineering blogs, API reference docs, and technical knowledge bases managed by software teams who already understand JSX syntax and pull request reviews.

Choosing the right editing layer

To pick the right setup for your project, evaluate who edits the content, what technical knowledge they possess, and how much infrastructure you want to maintain.

Editing ApproachContent LocationClient ExperienceBest Use CaseMonthly Software Cost
Raw MDXLocal repository filesHigh friction: requires code editor, Git, and JSX syntax awarenessInternal developer blogs and technical docsFree
Git CMS (Decap CMS)Local files via visual UIMedium friction: form fields and rich text directly in GitLow-budget client sites needing structured blogsFree
Visual Git CMS (TinaCMS)Local Markdown and MDX filesLow friction: visual sidebar and forms saving to GitStructured content sites with client editorsFree to low cost
In-Code Visual Editor (TurnIntoCMS)Source JSX and data filesLow friction: point-and-click editing on a live previewMarketing sites, landing pages, agency client handoffsFree for one project
Headless CMSThird-party databaseLow friction: full visual dashboard and asset managementHigh-volume editorial teams, multi-brand publishingModerate to high SaaS fees

A Git-based CMS can bridge the gap for teams that want content in the repository without exposing clients to raw files. For example, Decap CMS stores content in your repository alongside your code for easier versioning, operating as an open-source application that commits through your Git host API.

Similarly, TinaCMS commits each change back to Git as users update content in Markdown, MDX, or JSON files. According to the TinaCMS Markdown specification, TinaCMS has no build step when MDX is used, meaning JavaScript expressions and import or export statements are unsupported. Once you strip away dynamic logic to safeguard non-technical editors, MDX becomes little more than standard Markdown wrapped in form fields.

When clients need complete freedom to publish dozens of articles weekly, a headless CMS is often worth the investment. Storing copy in a dedicated content platform provides revision history, role permissions, and asset pipelines, though it introduces recurring monthly SaaS subscriptions and separates content from your source code. You can read more about these trade-offs in our guide on headless CMS versus content in code.

For standard marketing websites and freelance projects, TurnIntoCMS offers a practical middle ground. TurnIntoCMS connects directly to your GitHub repository and lets clients click text, links, and pictures on a live preview of the site, writing updates back as clean Git commits. It removes the risk of broken builds without requiring a database, an external CMS subscription, or exposure to fragile MDX syntax.

Guardrails if you must hand MDX to clients

If project constraints require you to give MDX files to a non-technical client, do not let them edit raw text files directly in GitHub. Apply these four safeguards to prevent production outages.

  1. Mount a visual interface over the files. The Keystatic MDX field reads and writes content in MDX, but users are responsible for rendering the MDX content. This prevents clients from ever viewing or typing raw JSX syntax.
  1. Restrict components to explicit schemas. Configure your visual editor so authors can only insert pre-approved UI elements. Whitelist specific components and their permitted props in your configuration while rejecting arbitrary HTML or unvetted attributes.
  1. Provide components globally. Non-technical clients should never have to write JavaScript import statements at the top of an article. Set up your global component mappings across all MDX routes so design system elements render automatically without manual imports.
  1. Add validation steps to your deployment pipeline. Configure continuous integration workflows with linting plugins to detect syntax errors before deployments run. Running linters in your build pipeline catches unclosed tags and malformed frontmatter before bad data hits your production servers.

Common MDX client handoff mistakes to avoid

  • Inviting non-technical clients to edit raw files in GitHub. Clients will inevitably delete a closing tag or paste smart quotes that break the build parser.
  • Missing the component configuration. Forgetting to configure component mapping files in your project causes missing component errors during local and production builds.
  • Allowing complex object literals in props. Avoid complex data structures like nested arrays in custom component props. Stick to primitive strings and booleans so editors do not encounter syntax errors.
  • Treating MDX as a relational database. MDX is a document authoring format, not a database. Avoid using MDX frontmatter for complex relational queries across categories, authors, and inventory.

FAQ

Does MDX help or hurt non-technical editors?

Raw MDX hurts non-technical editors because unescaped characters, missing closing tags, or broken component props crash the static build. It only works for non-technical teams if you place a visual Git-based editor on top of the files to hide the underlying syntax.

When does MDX make sense for a client project?

MDX makes sense when your content authors are technical staff who write in code editors and submit changes through Git pull requests. It also suits projects where content updates and custom React components must be versioned and deployed together in identical Git commits.

What is the difference between MDX and Markdoc for client sites?

MDX compiles directly into executable JavaScript and permits arbitrary React code, creating potential build errors and server security concerns. Markdoc treats content as structured data, validating custom tags against a strict schema without compiling raw executable JavaScript.

Why choose a visual Git editor over raw MDX?

A visual Git editor provides familiar rich-text fields and image upload tools while committing changes back to your repository. This eliminates the risk of clients introducing syntax errors while preserving the version control benefits of storing content in code.

Sources

  1. How to use markdown and MDX in Next.js (nextjs.org, checked November 20, 2026)
  2. @mdx-js/mdx | MDX (mdxjs.com, checked November 20, 2026)
  3. remark-mdx | MDX (mdxjs.com, checked November 20, 2026)
  4. Markdoc | Frequently asked questions (markdoc.dev, checked November 20, 2026)
  5. MDX field - Docs | Keystatic (keystatic.com, checked November 20, 2026)
  6. Markdown Syntax Guide (tina.io, checked November 20, 2026)
  7. Project structure and organization (nextjs.org, checked November 20, 2026)
  8. Decap CMS overview (decapcms.org, checked November 20, 2026)
  9. Get Started and learn about TinaCMS (tina.io, checked November 20, 2026)

Related

More from the blog

Let your clients edit the site you coded

One website free. Then $1 each, paid once.

Get started free