Zig runtime

Entry and registration

Import the package as napi and register public declarations at comptime:

const napi = @import("napi");

comptime {
    napi.module(@This());
}

src/root.zig is the public runtime entry. It exports c, dts, index_js, Error, Env, Val, BigIntFit, Callback, ThreadsafeFn, CallInfo, Ref, Deferred, class, and module.

Editing rules

  • Preserve Node-API ownership, lifetime, and error behavior.
  • Keep exported declarations compatible with automatic TypeScript declaration generation.
  • Cover new conversions and runtime behavior in src/tests.zig and tests/library/.
  • Cover public declaration shapes in tests/dts/ when types change.
  • Format Zig changes with zig fmt and run zig build test before broader tests.

Use the detailed pages beside this file for user-facing examples and individual exported types. Start with functions, type conversion, async workers, or the runtime API reference, depending on the affected surface.