@teakit/napi

@teakit/napi is a Zig toolkit for building Node-API addons. The Zig package and import name is napi; the npm CLI package, executable, and command name is napikit.

Minimal module

const napi = @import("napi");

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

pub fn add(a: i32, b: i32) i32 {
    return a + b;
}

Public contract

  • Runtime entry: src/root.zig.
  • Build entry: build.zig, especially addLib, LibOptions, NpmConfig, Dts, Import, and Platform.
  • CLI entry: napikit new, build, bump, publish, and npm-init.
  • napikit new pins the exact @teakit/napi source commit embedded at CLI build time and records an exact package-manager baseline.
  • Release commands require one common version across every generated and extra package and use the canonical npmjs registry.
  • Generated addons use .node binaries, JavaScript bindings, and optional declarations.
  • .dts = .none emits no declaration, types field, or index.d.ts package entry; development and release rebuilds remove their stale build-owned declarations when switching to .none without deleting unrelated .d.ts files.
  • Release optimization modes apply to every binding, and --current is valid only when the host is listed in .npm.platforms.
  • Toolchain baseline: Zig 0.16.0, Bun 1.3.14 for this repository, and Node.js >=20.19.0 for the published napikit CLI.
  • Public docs: https://napi.teakit.org.
  • Source repository: https://github.com/teakit/napi.

Reference map

Repository commands

bun install --frozen-lockfile
bun run check
bun run typecheck
bun run test
bun run build
bun run docs:build

Use teakit-napi/SKILL.md for task workflow, guardrails, and complete reference routing.

For repository maintenance, .github/workflows/quality.yml defines the five canonical checks and .github/workflows/publish-to-npm.yml releases the CLI. The addon scaffolder writes a separate .github/workflows/publish.yml into generated projects.