---
title: Safe subset
subtitle: ButterIX never executes author code when rendering MDX. This page explains what's allowed, what isn't, and why it's designed this way.
description: The ButterIX MDX safe subset — allowed imports, exports, expressions, and prop values, the HTML allowlist, rejected syntax and its diagnostics, and why arbitrary JavaScript isn't allowed.
---

## 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:

<CardGroup cols={2}>
  <Card title="Multi-tenant builds" icon="lucide:server">
    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.
  </Card>
  <Card title="Visual editing and previews" icon="lucide:pen-line">
    The editor renders drafts live on the dashboard's domain. Executable content would let one editor steal other collaborators' sessions.
  </Card>
  <Card title="Predictable static output" icon="lucide:package">
    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.
  </Card>
  <Card title="Reliably machine-editable" icon="lucide:bot">
    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.
  </Card>
</CardGroup>

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

| Syntax | Example | Notes |
|---|---|---|
| Components | `<Card title="Quickstart" href="./quickstart.mdx">` | Only built-in components; `biti components` lists them all |
| Literal props | `cols={2}`, `defaultOpen`, `tags={["AI", "MCP"]}` | Strings, numbers, booleans, `null`, arrays, plain objects |
| Template strings and concatenation | `` title={`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 value | `icon={<svg viewBox="0 0 24 24">…</svg>}` | Passed as data and rendered by the component |
| Page variables | `export const version = "1.2"` | Literals only (same rules as above) |
| Snippet imports | `import 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:

| Syntax | Diagnostic | Severity |
|---|---|---|
| `import { useState } from "react"` | `mdx/import`: only `.md` / `.mdx` snippets are supported | Error |
| `import { A } from "/snippets/a.mdx"` | `mdx/import`: named imports are ignored | Warning |
| `export function Foo() {}`, `export default …` | `mdx/esm`: unsupported top-level statement | Error |
| `onClick={() => alert(1)}` | `mdx/attribute`: props must be literals | Error |
| `{...props}` | `mdx/spread`: spread props aren't supported | Error |
| `{Date.now()}`, `{items.map(…)}` | `mdx/expression`: expression skipped | Warning |
| `lines={[1-3]}` | `mdx/attribute`: the `-` operator isn't allowed; write `"1-3"` | Error |
| `<script>`, `<style>`, `<form>`, `<button>` | `mdx/tag`: tag removed | Warning |
| `<MyWidget />` (unknown component) | `mdx/unknown-component`: only its children are rendered | Warning |

<Accordion title="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.
</Accordion>

## 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

| Before | After |
|---|---|
| Custom React components | Switch 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"` |
