Installation
ZNTC ships as a set of npm packages. Pick the ones you need based on the scenario.
Packages at a glance
Section titled “Packages at a glance”| Package | Purpose | Includes |
|---|---|---|
@zntc/core | CLI + Node/Bun in-process API (NAPI) | zntc binary, transpile() / build() / buildSync() / watch() / vitePlugin() |
@zntc/wasm | Browser · Edge · WASI runtimes | WASM-built transpiler |
@zntc/vite-plugin | Vite integration | Drop-in replacement for esbuild |
@zntc/react-native | React Native bundler / RN 0.72+ | Metro-compatible surface |
@zntc/init | Overlay ZNTC onto an existing RN CLI project | zntc-init scaffolder |
CLI + JS API (@zntc/core)
Section titled “CLI + JS API (@zntc/core)”The most common scenario. Provides both the zntc command and import { ... } from '@zntc/core'.
bun add -d @zntc/corenpm i -D @zntc/corepnpm add -D @zntc/coreyarn add -D @zntc/coredeno add -D npm:@zntc/coreThe CLI is available immediately after install:
bunx zntc --bundle src/index.ts -o dist/bundle.jsnpx zntc --bundle src/index.ts -o dist/bundle.jspnpm dlx zntc --bundle src/index.ts -o dist/bundle.jsyarn dlx zntc --bundle src/index.ts -o dist/bundle.jsdeno run -A npm:@zntc/core --bundle src/index.ts -o dist/bundle.jsJS API:
import { init, transpile, build, buildSync, vitePlugin } from "@zntc/core";
init();
// Transpileconst { code } = transpile("const x: number = 1;");
// Sync bundlingconst result = buildSync({ entryPoints: ["src/index.ts"], format: "esm", minify: true,});
// Async bundling with JS pluginsconst result2 = await build({ entryPoints: ["src/index.ts"], define: { "process.env.NODE_ENV": '"production"' }, plugins: [{ name: "css-plugin", setup(build) { build.onLoad({ filter: /\.css$/ }, () => ({ contents: 'export default "red";', })); }, }],});
// Vite/Rollup plugin adapterconst result3 = await build({ entryPoints: ["src/index.ts"], plugins: [ vitePlugin({ name: "env-replace", transform(code) { return code.replace("import.meta.env.MODE", '"production"'); }, }), ],});@zntc/core automatically pulls in the matching native binary (@zntc/core-darwin-arm64, @zntc/core-linux-x64-gnu, …) as an optional dependency.
WASM — Browser / Edge / WASI
Section titled “WASM — Browser / Edge / WASI”For environments without Node.js (browser playgrounds, Cloudflare Workers, Deno):
bun add @zntc/wasmnpm i @zntc/wasmpnpm add @zntc/wasmyarn add @zntc/wasmdeno add npm:@zntc/wasmimport { init, transpile } from "@zntc/wasm";
await init();const result = transpile("const x: number = 1;");console.log(result.code); // "const x = 1;"Vite plugin
Section titled “Vite plugin”Drop-in replacement for esbuild:
bun add -d @zntc/vite-pluginnpm i -D @zntc/vite-pluginpnpm add -D @zntc/vite-pluginyarn add -D @zntc/vite-plugindeno add -D npm:@zntc/vite-pluginimport { defineConfig } from "vite";import zntc from "@zntc/vite-plugin";
export default defineConfig({ plugins: [zntc()],});React Native
Section titled “React Native”Overlay ZNTC onto an existing React Native CLI project — one-shot:
bunx @zntc/initnpx @zntc/initpnpm dlx @zntc/inityarn dlx @zntc/initdeno run -A npm:@zntc/initSee the React Native guide for the full option list.
Direct install:
bun add -d @zntc/core @zntc/react-nativenpm i -D @zntc/core @zntc/react-nativepnpm add -D @zntc/core @zntc/react-nativeyarn add -D @zntc/core @zntc/react-nativedeno add -D npm:@zntc/core npm:@zntc/react-nativeGlobal install (CLI only)
Section titled “Global install (CLI only)”To use the zntc command system-wide, independent of any specific project:
bun add -g @zntc/corenpm i -g @zntc/corepnpm add -g @zntc/coreyarn global add @zntc/coredeno install -A -g npm:@zntc/coreBuild from source (contributors / latest main)
Section titled “Build from source (contributors / latest main)”If you want to run the latest main (or your own modifications) instead of the published npm version:
Prerequisites
Section titled “Prerequisites”- Zig 0.15.2 (install via mise recommended)
- Bun 1.3+ or Node.js 24+
- Git
git clone https://github.com/ohah/zntc.gitcd zntczig build -Doptimize=ReleaseFastBuilt binary: zig-out/bin/zntc. Add it to PATH and it works the same as the npm-installed CLI:
# ~/.zshrc or ~/.bashrcexport PATH="$PATH:/path/to/zntc/zig-out/bin"To rebuild the NAPI / WASM artifacts directly:
zig build napi # native binary for @zntc/corezig build wasm wasm-bundler # .wasm for @zntc/wasm