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:
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.
The editor renders drafts live on the dashboard's domain. Executable content would let one editor steal other collaborators' sessions.
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.
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
| 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 |
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, thetablefamily,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/relona,src/alt/width/height/srcsetonimg, andallow/allowfullscreenoniframe. - URL checks:
javascript:,vbscript:, and non-imagedata:URLs are dropped. - Style checks: CSS containing
expression(,javascript:,behavior:, and the like is dropped. - Event attributes (
onclickand 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" |