Quick start
The fastest path to a working addon is the scaffolder. It picks up your package manager, writes a starter project, installs everything, and produces a built binary you can import from Node.
Prerequisites
- Zig
0.16.0. - Node.js
>=20.19.0to runnapikit, plus a package manager (npm,pnpm,yarn, orbun). - If you choose Bun, use Bun
1.3.14, matching the generated workflow baseline.
Scaffold
The CLI prompts for any missing details, then:
- Writes
build.zig,build.zig.zon, andpackage.json. - Drops a starter
src/lib.zigwith two example functions. - Installs
napikitfrom npm and fetches the Zig dependency. - Adds a
.github/workflows/publish.ymlready for trusted publishing. - Runs an initial build so the binary is available immediately.
Try it
That's it. You have a working native Node.js addon written in Zig.
What the starter contains
The development loop
Every iteration is the same two-step:
napikit build compiles for the current host. When you are ready to ship, napikit build --release cross-compiles every platform at once. See Cross-compiling.
Next steps
- Functions covers everything you can put after
pub fn. - Type conversion is the table of which Zig types map to which JS types.
- Project layout is a one-stop map of every file in the project.