vercel-zig-runtime
v0.3.0
Published
Zig runtime for Vercel Serverless Functions
Maintainers
Readme
vercel-zig
Zig runtime for Vercel Serverless Functions. Compiles Zig projects and deploys them as native provided.al2023 Lambda functions with zero cold start overhead.
Quick Start
Add to your vercel.json:
{
"builds": [
{
"src": "main.zig",
"use": "vercel-zig-runtime"
}
],
"routes": [
{ "handle": "filesystem" },
{ "src": "/(.*)", "dest": "/main" }
]
}Your Zig project needs a build.zig with a vercel build step that produces a bootstrap binary targeting x86_64-linux. The binary must implement the AWS Lambda custom runtime API (poll AWS_LAMBDA_RUNTIME_API for events).
Configuration
| Option | Default | Description |
|--------|---------|-------------|
| buildStep | "vercel" | Zig build step name |
| binaryName | "bootstrap" | Output binary name in zig-out/bin/ |
{
"builds": [
{
"src": "main.zig",
"use": "vercel-zig-runtime",
"config": {
"buildStep": "docs-vercel"
}
}
]
}How It Works
- Downloads and caches Zig 0.15.2 on first build
- Cross-compiles your project for Linux x86_64
- Packages the binary as a native
provided.al2023Lambda function - Caches
.zig-cachebetween deploys for faster rebuilds
No Node.js, no shims, no runtime layers. The Zig binary runs directly on Lambda.
Build Step
Your build.zig needs a step that the runtime can invoke. By default it looks for vercel:
const vercel_exe = b.addExecutable(.{
.name = "bootstrap",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
}),
});
const vercel_step = b.step("vercel", "Build for Vercel");
vercel_step.dependOn(&b.addInstallArtifact(vercel_exe, .{}).step);License
Apache 2.0
