Skip to main content
Ant JavaScript Runtime

Ant-sized JavaScript runtime

Ant is a lightweight, high-performance JavaScript runtime built from the ground up. It’s designed to be small, fast, and feature-complete, bringing modern JavaScript capabilities to environments where size and efficiency matter.

Modern JavaScript

Full ES2024+ support with async/await, modules, classes, and more

Built-in HTTP server

Create web servers with the native Ant.serve() API

Crypto & security

Built-in cryptographic primitives powered by libsodium

File system access

Full sync and async file system APIs

Key features

Full async/await support

Ant provides complete async/await functionality with promises, allowing you to write clean asynchronous code:
async function fetchData() {
  const response = await fetch('https://api.github.com/zen');
  return await response.text();
}

const data = await fetchData();
console.log(data);

ES module system

Import and export modules using standard ES module syntax. Ant supports both relative imports and the special ant: prefix for built-in modules:
import { readFile, writeFile } from 'ant:fs';
import { join } from 'ant:path';
import { createRouter } from './router.js';

Native HTTP server

Build HTTP servers with the built-in Ant.serve() API. No external dependencies required:
function handleRequest(c) {
  const { req, res } = c;
  res.body(`Hello from Ant ${Ant.version}!`);
}

console.log('Server running on http://localhost:8000');
Ant.serve(8000, handleRequest);

HTTP client with fetch

Make HTTP requests using the familiar fetch API:
const response = await fetch('https://api.example.com/data');
const json = await response.json();
console.log(json);

File system operations

Both synchronous and asynchronous file system operations are supported:
import fs from 'ant:fs';
import path from 'ant:path';

// Synchronous
const content = fs.readFileSync('file.txt', 'utf8');
fs.writeFileSync('output.txt', 'hello world');

// Asynchronous
const data = await fs.readFile('file.txt');
await fs.writeFile('output.txt', data);

Cryptography and security

Built-in cryptographic functions powered by libsodium:
import crypto from 'ant:crypto';

const hash = crypto.hash('sha256', 'hello world');
const random = crypto.randomBytes(32);

Worker threads

Run JavaScript in parallel using worker threads:
import { Worker } from 'ant:worker_threads';

const worker = new Worker('./worker.js');
worker.postMessage({ task: 'process' });
worker.on('message', (result) => {
  console.log('Worker result:', result);
});

Process management

Spawn child processes and execute shell commands:
import { spawn, exec } from 'ant:child_process';

const child = spawn('ls', ['-la']);
child.stdout.on('data', (data) => {
  console.log(data.toString());
});

Built-in database (LMDB)

Embedded key-value database using LMDB:
import lmdb from 'ant:lmdb';

const db = lmdb.open('./data');
db.put('key', 'value');
const value = db.get('key');

Storage APIs

Browser-compatible localStorage and sessionStorage:
localStorage.setItem('user', JSON.stringify({ name: 'Alice' }));
const user = JSON.parse(localStorage.getItem('user'));

sessionStorage.setItem('token', 'abc123');
Ant is built with C23 using modern tooling including Meson, Rust (for the OXC type-strip library), and Zig (for the package manager). It supports Linux, macOS, and Windows.

Next steps

Installation

Install Ant on your system in seconds

Quick start

Build your first Ant application

Community

Join the Ant community on Discord to ask questions, share projects, and contribute to the runtime. Read the blog post about Ant to learn about the project’s origins and design philosophy.

Build docs developers (and LLMs) love