Faster Initial Layout
1.5-2.5x faster than Yoga for initial layout. JS node creation avoids WASM boundary crossings (~8x cheaper per node).
Need flexbox layout outside the browser? Yoga requires WASM, async init, and leaks memory in long-running apps. Flexily is a pure JavaScript drop-in replacement β 1.5-5.5x faster, 3x smaller, no WASM. Powers Silvery's terminal UI layout.
npm install flexilybun add flexilypnpm add flexilyyarn add flexilyimport { createFlexily, FLEX_DIRECTION_ROW } from "flexily"
const flex = createFlexily()
const root = flex.createNode()
root.setWidth(100)
root.setFlexDirection(FLEX_DIRECTION_ROW)
const child = flex.createNode()
child.setFlexGrow(1)
root.insertChild(child, 0)
flex.calculateLayout(root, 100, 100)
console.log(child.getComputedWidth()) // 100Build your own Flexily instance with only the plugins you need:
import { createBareFlexily, pipe, withTestMeasurer } from "flexily"
const flex = pipe(createBareFlexily(), withTestMeasurer())Available plugins: withMonospaceMeasurer() (terminal), withTestMeasurer() (deterministic), withPretextMeasurer() (proportional fonts via Pretext).
For direct Yoga-compatible usage without the composable engine:
import { Node, FLEX_DIRECTION_ROW, DIRECTION_LTR } from "flexily"
const root = Node.create()
root.setWidth(100)
root.setFlexDirection(FLEX_DIRECTION_ROW)
const child = Node.create()
child.setFlexGrow(1)
root.insertChild(child, 0)
root.calculateLayout(100, 100, DIRECTION_LTR)
console.log(child.getComputedWidth()) // 100Most developers should use a framework built on Flexily, not Flexily directly. Flexily is for:
Building a terminal UI? Use Silvery, which uses Flexily by default. You get React components, hooks, and layout feedback without touching the low-level API.