Command Line Interface
ZX comes with a built-in CLI tool to help you create, develop, and deploy your projects.
Installation
Install the ZX CLI using one of the following methods:
Commands
init
Initialize a new ZX project. Creates all the necessary files and directory structure to get started with ZX.
Arguments
[path]— Path to initialize the project in (default: current directory)
Flags
--template, -t <name>— Template to use (default:"default"). Options:default,react,wasm,react_wasm--force, -f— Force initialization even if the directory is not empty
--force to override.dev
Start the app in development mode with hot reloading. Watches for file changes and automatically rebuilds.
Flags
--binpath, -b <path>— Binpath of the app (default: auto-detected)--build-args <args>— Additional arguments to pass tozig build
serve
Serve the project for production. Builds and runs the executable.
Flags
--port, -p <number>— Port to run the server on (default:3000)
transpile
Transpile .zx files to Zig source code. Useful for debugging or inspecting generated code.
Arguments
<path>— Path to.zxfile or directory (required)
Flags
--outdir, -o <directory>— Output directory (default:".zx")
fmt Alpha
Format ZX source code files according to ZX's formatting rules.
Arguments
[path]— Path to.zxfile or directory (optional, formats current directory if not specified)
Flags
--stdio— Read from stdin and write to stdout--stdout— Write formatted output to stdout instead of modifying files
export
Generate static site assets. Builds your project and exports it for static hosting.
Flags
--outdir, -o <directory>— Output directory (default:"dist")--binpath, -b <path>— Binpath of the app executable (default: auto-detected)
zig build first to build the ZX executable before exporting.bundle
Bundle the site into a deployable directory with the executable and assets.
Flags
--outdir, -o <directory>— Output directory (default:"bundle")--binpath, -b <path>— Binpath of the app executable (default: auto-detected)
zig build first to build the ZX executable before bundling.update
Update the ZX dependency version in your project's build.zig.zon file.
Flags
--version, -v <version>— Version to update to (default:"latest")
upgrade
Upgrade the ZX CLI tool itself. Downloads and installs a new version of the CLI binary.
Flags
--version, -v <version>— Version to upgrade to (default:"latest")
version
Show the current version of the ZX CLI tool.