Skip to main content
Ant runs JavaScript and TypeScript files directly — no configuration files, no build step, no separate transpiler. This guide walks you from a single console.log to a full HTTP server powered by Hono in about five minutes.
1

Run a JavaScript file

Create a file called hello.js:
hello.js
console.log('Hello from Ant ' + Ant.version);
Run it:
ant hello.js
You should see the greeting printed with the current Ant version. The global Ant object is always available and exposes runtime metadata.
2

Run a TypeScript file

Ant strips TypeScript types at load time using the built-in OXC-based type stripper. No tsconfig.json, no tsc, no separate build step.Create hello.ts:
hello.ts
function greet(name: string): string {
  return `Hello, ${name}!`;
}

console.log(greet('Ant'));
Run it exactly like a .js file:
ant hello.ts
Type checking is not performed at runtime — Ant strips annotations and runs the result. Use your editor’s language server or tsc --noEmit if you want type errors caught before execution.
3

Evaluate an expression inline

For quick one-liners, use the -e flag to pass a script directly on the command line:
ant -e "console.log('hello')"
This is useful for scripting and shell pipelines where you don’t want to create a temporary file.
4

Start an HTTP server

Ant’s HTTP server follows the WinterTC fetch handler pattern: export a default object with a fetch method, and Ant starts listening automatically.Create server.js:
server.js
export default {
  port: 3000,
  fetch(req, server) {
    const url = new URL(req.url);

    if (url.pathname === '/') {
      return new Response(`Welcome to Ant ${Ant.version}!`);
    }

    return new Response('not found', { status: 404 });
  }
};
Run it:
ant server.js
Open http://localhost:3000 in your browser or hit it with curl:
curl http://localhost:3000
The server argument passed to fetch exposes the server instance. You can call server.stop() from inside a handler to shut the server down programmatically — useful for ephemeral servers in scripts or tests:
ephemeral_server.js
let count = 0;
const MAX_REQUESTS = 10;

console.log('starting on http://localhost:3000');

export default {
  fetch(req, server) {
    if (new URL(req.url).pathname.includes('favicon')) {
      return new Response(null, { status: 404 });
    }

    count++;

    if (count === MAX_REQUESTS) {
      console.log('10 requests served, stopping');
      server.stop();
    }

    return Response.json({
      request: count,
      remaining: Math.max(0, MAX_REQUESTS - count)
    });
  }
};
5

Add an npm package and build a Hono server

Ant resolves npm packages from a local node_modules directory. Add a package with ant add:
ant add hono
Then create index.ts:
index.ts
import { Hono } from 'hono';
import { logger } from 'hono/logger';

const app = new Hono();

app.use(logger());
app.get('/', c => c.text(`hello hono!!\n\n🐜 ${Ant.version}\n`));

console.log('started on http://localhost:3000');

export default app;
Run it:
ant index.ts
Hono’s default export is a WinterTC-compatible handler, so Ant picks it up automatically and starts the server. Visit http://localhost:3000 to see the response.
Exporting a Hono app instance as the default export works because Hono implements the fetch(req) interface that Ant’s HTTP server expects.
6

Open the interactive REPL

Run ant with no arguments to enter the interactive REPL:
ant
The REPL supports the full Ant runtime, including await at the top level, built-in modules, and the Ant global. Press Ctrl+D or type .exit to quit.
> Ant.version
'0.9.1'
> await fetch('https://api.github.com/zen').then(r => r.text())
'Keep it logically awesome.'

What to explore next

Built-in modules

Ant ships built-in modules for the file system, path, crypto, streams, and more — importable via the ant: prefix (e.g. import { readFile } from 'ant:fs').

FFI

Call native shared libraries from JavaScript using Ant’s Foreign Function Interface.

WebAssembly

Run .wasm modules directly in Ant alongside your JavaScript code.

Embedding Ant

Embed the Ant runtime in your own C or C++ application via the libant C API.