A lightweight JavaScript runtime built with Zig and QuickJS.
Kiren is designed for building fast, standalone server applications with minimal footprint. It provides Node.js-compatible APIs while maintaining a small binary size and fast startup time.
- Fast startup - QuickJS-based engine with minimal overhead
- Small binary - Single executable under 4MB
- Bundle to executable - Create standalone apps with
kiren bundle - HTTP server - Native Zig HTTP server with high throughput
- WebSocket support - Built-in WebSocket server with rooms
- SQLite database - Native SQLite for embedded data storage
- Static file serving - Built-in static middleware with MIME detection
- Node.js compatibility - Familiar APIs (fs, path, Buffer, etc.)
- Module system - CommonJS require/exports
- No dependencies - Self-contained runtime, no npm required
// server.js
const express = require("express");
const app = express();
app.get("/", function(req, res) {
res.json({ message: "Hello from Kiren!" });
});
app.listen(3000, function() {
console.log("Server running on http://localhost:3000");
});kiren server.jsRequires Zig 0.14.0 or later.
git clone https://github.com/user/kiren.git
cd kiren
zig build -Doptimize=ReleaseFastThe binary will be available at zig-out/bin/kiren.
Coming soon.
# Run a script
kiren script.js
# Run with arguments
kiren server.js --port 8080Kiren.serve({
port: 3000,
fetch: function(req) {
return new Response(JSON.stringify({ ok: true }), {
headers: { "Content-Type": "application/json" }
});
}
});Kiren.ws({
port: 8080,
open: function(ws) {
Kiren.wsSend(ws, "Welcome!");
},
message: function(ws, data) {
Kiren.wsBroadcast(data);
}
});const content = fs.readFileSync("config.json", "utf8");
fs.writeFileSync("output.txt", "Hello World");const fullPath = path.join(__dirname, "data", "file.txt");
const ext = path.extname("script.js"); // ".js"const buf = Buffer.from("Hello");
const encoded = buf.toString();const response = fetch("https://api.example.com/data");
const data = response.json();const db = Kiren.sqlite(':memory:');
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
db.run('INSERT INTO users (name) VALUES (?)', ['Mert']);
const users = db.query('SELECT * FROM users');
console.log(users); // [{ id: 1, name: 'Mert' }]
db.close();const express = require("express");
const app = express();
// Serve static files from ./public directory
app.use(express.static("./public"));
app.listen(3000);# Create standalone executable
kiren bundle server.js -o server
# Run without kiren installed
./serverFor complete API documentation, see docs/API.md.
Kiren includes drop-in replacements for popular npm packages:
| Package | Status |
|---|---|
| express | Supported |
| axios | Supported |
| jsonwebtoken | Supported |
| dotenv | Supported |
| uuid | Supported |
const express = require("express");
const axios = require("axios");
const jwt = require("jsonwebtoken");
require("dotenv").config();kiren/
├── src/ # Zig source code
│ ├── main.zig # Entry point
│ ├── engine.zig # QuickJS bindings
│ └── api/ # JavaScript API implementations
├── lib/ # JavaScript compatibility libraries
├── deps/ # Dependencies (QuickJS, SQLite)
├── tests/ # Test files
├── examples/ # Example applications
└── docs/ # Documentation
Kiren achieves approximately 20,000 requests/second on a single core for simple JSON responses, comparable to other lightweight runtimes.
Contributions are welcome. Please read CONTRIBUTING.md before submitting a pull request.
MIT License