Skip to content

ButterIX v1 is out: versions, multiple languages, Ask AI, and a per-site MCP server, all built in. →

Safe subset

ButterIX never executes author code when rendering MDX. This page explains what's allowed, what isn't, and why it's designed this way.

Why arbitrary JavaScript isn't allowed

Standard MDX compiles every file into a JavaScript module: import can pull in any package, {} can hold any expression, and components can run arbitrary code on the build machine and in readers' browsers. That's convenient for a solo project, but unacceptable for ButterIX:

Multi-tenant builds

The hosted platform builds every site on the same pool of build machines. If MDX could execute code, anyone could read environment variables, reach the internal network, or tamper with other tenants' output.

Visual editing and previews

The editor renders drafts live on the dashboard's domain. Executable content would let one editor steal other collaborators' sessions.

Predictable static output

With no runtime code, pages are pure HTML: zero hydration, a very fast first paint, and search engines and AI crawlers see exactly what readers see.

Reliably machine-editable

Component props are all literal data, so the visual editor, AI translation, and coding agents can read and write pages losslessly without having to understand an arbitrary program.

So ButterIX parses MDX as data: components come from a fixed allowlist of built-in implementations, and props are safely evaluated into JSON values at build time, then handed to React server rendering.

What's allowed

SyntaxExampleNotes
Components<Card title="Quickstart" href="./quickstart.mdx">Only built-in components; biti components lists them all
Literal propscols={2}, defaultOpen, tags={["AI", "MCP"]}Strings, numbers, booleans, null, arrays, plain objects
Template strings and concatenationtitle={`v${version}`}, {"v" + version}Only + is supported
Unary and ternary operators{-1}, {!hidden}, {beta ? "Beta" : "GA"}
Member access{plans.pro.price}Only own properties of literals
JSX as a prop valueicon={<svg viewBox="0 0 24 24">…</svg>}Passed as data and rendered by the component
Page variablesexport const version = "1.2"Literals only (same rules as above)
Snippet importsimport Install from "/snippets/install.mdx"Only .md / .mdx, default imports only
Safe HTML<div>, <img />, <iframe>, <details>, <svg>Element and attribute allowlist; see below

What's not allowed

Each of these produces a clear diagnostic, and biti check points to the file and line:

SyntaxDiagnosticSeverity
import { useState } from "react"mdx/import: only .md / .mdx snippets are supportedError
import { A } from "/snippets/a.mdx"mdx/import: named imports are ignoredWarning
export function Foo() {}, export default …mdx/esm: unsupported top-level statementError
onClick={() => alert(1)}mdx/attribute: props must be literalsError
{...props}mdx/spread: spread props aren't supportedError
{Date.now()}, {items.map(…)}mdx/expression: expression skippedWarning
lines={[1-3]}mdx/attribute: the - operator isn't allowed; write "1-3"Error
<script>, <style>, <form>, <button>mdx/tag: tag removedWarning
<MyWidget /> (unknown component)mdx/unknown-component: only its children are renderedWarning
Extra restrictions on object props

Computed keys ({[key]: 1}), methods, getters / setters, and __proto__ keys are all rejected; member access doesn't allow __proto__, constructor, or prototype. Regular expression literals aren't allowed either.

HTML allowlist

Lowercase tags are treated as HTML, and only elements and attributes on the allowlist are output:

  • Elements: common text and structural elements (div, span, p, section, the table family, ul / ol / li, details / summary, figure, kbd, mark, and so on), media elements (img, picture, source, video, audio, track, iframe), and SVG graphics elements.
  • Global attributes: id, class / className, style, title, lang, dir, role, hidden, tabIndex.
  • Element-specific attributes: for example href / target / rel on a, src / alt / width / height / srcset on img, and allow / allowfullscreen on iframe.
  • URL checks: javascript:, vbscript:, and non-image data: URLs are dropped.
  • Style checks: CSS containing expression(, javascript:, behavior:, and the like is dropped.
  • Event attributes (onclick and friends) are never output under any circumstances.

So where does interactivity come from?

Interactivity is provided centrally by ButterIX's own browser script: tab switching, code copying, accordions, tooltips, search, Ask AI, the API playground, and so on are all behaviors of built-in components, implemented through event delegation. Each page loads only a tiny entry script, and heavy features load on demand.

If you really need site-level custom behavior (such as adding a support chat widget), you can include a script with js: in docs.yml — it's completely separate from how page content is parsed, and the site owner is responsible for it. The visual editor preview doesn't load these scripts.

Migrating from standard MDX

BeforeAfter
Custom React componentsSwitch to the closest built-in component; run biti components to see props
export const Foo = () => <div/>Move the content to snippets/foo.mdx, then import Foo from "/snippets/foo.mdx"
{new Date().getFullYear()}Write a literal, or use export const year = 2026
{data.map(item => <Card …/>)}Expand into multiple <Card> elements
lines={[1-3]}, highlight={[1-3]}lines="1-3", highlight="1-3"