forma-ir
FMIR binary format parser, walker, and HTML generator for the Forma Stack. Parses compiled component IR and generates server-rendered HTML with hydration markers — no JavaScript runtime needed.
Install
[]
= "0.1"
What It Does
- Parses
.irbinary files (FMIR format) into a validatedIrModule - Walks the opcode stream and generates HTML with proper escaping
- Fills dynamic values (text, attributes, conditionals, lists) from typed
SlotData - Emits hydration markers (
<!--f:t0-->,<!--f:s0-->, etc.) for FormaJS client-side hydration - Compiles to WASM for client-side island re-renders
Quick Start
use ;
// Parse a compiled .ir binary
let module = parse?;
// Fill slots with runtime data
let slots = from_json?;
// Generate HTML
let html = walk_to_html?;
When You Need This
- Building your own server (not Axum) — parse IR and generate HTML yourself
- Client-side WASM — re-render islands in the browser without a server round-trip
- Build tools — inspect, transform, or generate IR files
If you're using Axum, use forma-server instead — it wraps forma-ir with page rendering, asset serving, and CSP headers.
Security
- All dynamic text and attributes are HTML-escaped
- Recursion depth limited to 64 (prevents stack overflow from malicious IR)
- List nesting limited to 4 levels
- Comment content escaped (
--→--) - Script tag props escaped (
</script>→<\/script>) - Zero
unsafeblocks - 126 tests including XSS payload verification
Part of the Forma Stack
Frontend (TypeScript)
| Package | Description |
|---|---|
| @getforma/core | Reactive DOM library — signals, h(), islands, SSR hydration |
| @getforma/compiler | Vite plugin — h() optimization, server transforms, FMIR emission |
| @getforma/build | Production pipeline — bundling, hashing, compression, manifest |
Backend (Rust)
| Package | Description |
|---|---|
| forma-ir | This crate — FMIR parser, walker, WASM exports |
| forma-server | Axum middleware — SSR, asset serving, CSP headers |
Full Framework
| Package | Description |
|---|---|
| @getforma/create-app | npx @getforma/create-app — scaffolds Rust server + TypeScript frontend |
License
MIT