Dinja
Safe, deterministic MDX rendering powered by a Rust core with batteries-included Python bindings.
Dinja is a high-performance MDX renderer that combines the speed of Rust with the ease of Python, providing identical output across both languages.
Why Dinja?
- 🚀 Native Performance – The renderer is written in Rust and avoids Node.js runtime costs
- 🔄 Identical Output – Both the Rust crate and Python bindings call into the same engine
- ⚡ Zero Setup – Static JS dependencies are embedded and extracted on demand
- 📦 Prebuilt Binaries – PyPI ships wheels for Linux, macOS (x86/arm), and Windows (abi3-py313+)
- 🛡️ Safe & Deterministic – No external dependencies, predictable rendering behavior
Quick Example
Features
Multiple Output Formats
Dinja supports three output formats:
- HTML – Rendered HTML ready for display
- JavaScript – Transformed JavaScript code
- Schema – Component schema representation
Component Support
Define custom components and use them in your MDX:
from dinja import Renderer, Input, Settings
components = {
"Button": "function Component(props) { return <button>{props.children}</button>; }"
}
renderer = Renderer()
result = renderer.render(
Input(
mdx={"page.mdx": "# Hello <Button>Click me</Button>"},
settings=Settings(),
components=components,
)
)
Automatic Retry Logic
The Python Renderer class includes automatic retry logic for transient v8 isolate errors:
Installation
What's Next?
- Installation Guide – Get started with Dinja
- Quick Start – Your first MDX render
- Python API Reference – Complete Python documentation
- Rust API Reference – Complete Rust documentation
License
BSD 3-Clause. See LICENSE for details.