New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

bun-yoga

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-yoga

FFI wrapper for Facebook's Yoga layout engine for Bun

latest
Source
npmnpm
Version
0.2.12
Version published
Weekly downloads
2
-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

bun-yoga

A fast FFI wrapper for Facebook's Yoga layout engine, providing a yoga-layout compatible API for Bun.

Why FFI over NAPI?

Benchmarks showed FFI is faster than NAPI for this use case.

Supported Platforms

Pre-built binaries are included in the npm package for:

PlatformArchitectureBinary
macOSARM64 (Apple Silicon)libyoga.dylib
macOSx64 (Intel)libyoga.dylib
Linuxx64libyoga.so
LinuxARM64libyoga.so
Windowsx64yoga.dll

The correct binary is automatically loaded at runtime based on your platform.

Installation

bun add bun-yoga

Usage

import Yoga, { Node, Config, Edge, FlexDirection } from "bun-yoga";

const config = Config.create();
const root = Node.create(config);

root.setFlexDirection(FlexDirection.Column);
root.setWidth(100);
root.setHeight(100);

const child = Node.create(config);
child.setFlexGrow(1);
root.insertChild(child, 0);

root.calculateLayout(100, 100);
console.log(root.getComputedLayout());
// { left: 0, top: 0, right: 0, bottom: 0, width: 100, height: 100 }

root.freeRecursive();
config.free();

API

The API mirrors yoga-layout. All enums, constants, and methods are compatible.

Building from source

Requires Zig 0.15+:

zig build -Doptimize=ReleaseFast

License

MIT

FAQs

Package last updated on 02 Dec 2025

Related posts