Command Line Interface
ZX comes with a built-in CLI tool to help you manage your project.
Installation
Install the ZX CLI using one of the following methods:
Linux/macOS
curl -fsSL https://ziex.dev/install | bashWindows
powershell -c "irm ziex.dev/install.ps1 | iex"Installing Zig
brew install zig # macOS
winget install -e --id zig.zig # WindowsCommands
init
zx init [flags]Initialize a new ZX project in the current directory. This command creates all the necessary files and directory structure to get started with ZX.
- --template, -t
nameTemplate to use (default:
"default"). Available options:
build.zig.zon already exists in the current directory.
dev
zx dev [flags]Start the app in development mode with hot reloading. This command watches for changes in your files and automatically rebuilds the project when changes are detected. It also builds TypeScript/JavaScript files if present.
- --binpath, -b
pathBinpath of the app in case you have multiple executable artifacts or are using a custom
zig-outdirectory (default: empty, auto-detected) - --build-args
argsAdditional build arguments to pass to
zig build(space-separated)
zx dev --build-args "--release-fast"serve
zx serve [flags]Serve the project for production. This command builds and runs the executable, starting the development server.
- --port, -p
numberPort to run the server on (default:
3000)
zx serve --port 8080transpile
zx transpile path [flags]Transpile .zx files to Zig source code. This is useful for debugging, inspecting the generated code, or understanding how ZX transforms your JSX-like syntax into Zig.
pathPath to
.zxfile or directory containing.zxfiles (required)
- --outdir, -o
directoryOutput directory for transpiled Zig files (default:
".zx")
# Transpile a single file
zx transpile site/pages/page.zx
# Transpile a directory
zx transpile site/pages --outdir site/.zx
# Transpile and output to stdout (when using default outdir with a file)
zx transpile site/pages/page.zxfmt
zx fmt [path] [flags]Format ZX source code files. This command automatically formats your .zx files according to ZX's formatting rules. (Alpha)
- [path]
Path to
.zxfile or directory (optional, formats current directory if not specified)
- --stdio
Read from stdin and write formatted output to stdout
- --stdout
Write formatted output to stdout instead of modifying files on disk
# Format all .zx files in current directory
zx fmt
# Format a specific file
zx fmt site/pages/page.zx
# Format and output to stdout
zx fmt site/pages/page.zx --stdout
# Format from stdin
cat file.zx | zx fmt --stdioexport
zx export [flags]Generate static site assets. This command builds your project and exports it as a static site, generating HTML files for all routes. Useful for deploying to static hosting services.
- --outdir, -o
directoryOutput directory for exported static files (default:
"dist") - --binpath, -b
pathBinpath of the app executable (default: auto-detected)
zx export --outdir ./buildzig build first to build the ZX executable before exporting.
update
zx update [flags]Update the version of the ZX dependency in your project's build.zig.zon file. This updates the ZX library version used by your project, not the CLI tool itself.
- --version, -v
versionVersion to update to (default:
"latest"). Can be a specific version like0.0.1-dev.307or"latest"for the latest release
# Update to latest version
zx update
# Update to specific version
zx update --version 0.0.1-dev.307upgrade
zx upgrade [flags]Upgrade the version of the ZX CLI tool itself. This downloads and installs a new version of the CLI binary.
- --version, -v
versionVersion to upgrade to (default:
"latest"). Can be a specific version like0.0.1-dev.307or"latest"for the latest release
# Upgrade to latest version
zx upgrade
# Upgrade to specific version
zx upgrade --version 0.0.1-dev.307version
zx versionShow the current version of the ZX CLI tool. This command displays the installed CLI version, which may differ from the ZX library version used in your project.