Zig is becoming an increasingly attractive choice for building native Node.js modules. But the JavaScript binding layer still feels stuck in 2015.
Even the simplest native function requires repetitive plumbing. For every useful line of logic, you write several lines of binding code.
While building native infrastructure, we kept running into this problem repeatedly inside zapi, a Zig N-API wrapper library and CLI for building and publishing cross-platform Node.js native addons.
We wanted a way to preserve full control over Node's N-API when needed while dramatically simplifying the common path. The result is a new high-level DSL introduced in zapi that lets you write plain Zig functions and automatically turns them into JavaScript APIs at compile time.
The DSL is already powering production bindings in lodestar-z, where we are migrating Lodestar, ChainSafe's Ethereum consensus client, from JavaScript to Zig.