Skip to main content
Get up and running with Ant in minutes. This guide will walk you through creating a simple HTTP server that responds to requests.
1

Install Ant

Run the installation script to get the latest version of Ant:
curl -fsSL https://ant.themackabu.com/install | bash
Verify the installation:
ant --version
You should see the Ant version printed to your terminal.
2

Create your first server

Create a new file called server.js with the following code:
server.js
function handleRequest(c) {
  const { req, res } = c;
  
  if (req.uri === '/') {
    res.body(`Welcome to Ant ${Ant.version}!`);
  } else if (req.uri === '/hello') {
    res.body('Hello, World!');
  } else if (req.uri === '/json') {
    res.json({ message: 'Hello from Ant!', timestamp: Date.now() });
  } else {
    res.body('not found: ' + req.uri, 404);
  }
}

console.log('Server running on http://localhost:8000');
Ant.serve(8000, handleRequest);
This creates a simple HTTP server with three routes:
  • / - Welcome message with version
  • /hello - Simple greeting
  • /json - JSON response with timestamp
3

Run the server

Start your server with the ant command:
ant server.js
You should see:
Server running on http://localhost:8000
Your server is now running and ready to handle requests!
4

Test your server

Open a new terminal and test the endpoints with curl:
curl http://localhost:8000/
# Welcome to Ant 0.0.1!
Press Ctrl+C in the server terminal to stop the server.

Next steps

Now that you have a working server, explore more features:

HTTP Server Guide

Learn about routing, async handlers, and advanced features

API Reference

Explore the complete Ant API documentation

File System

Read and write files with async/await

Fetch API

Make HTTP requests to external APIs

What you learned

In this quickstart, you:
  • Installed Ant on your system
  • Created a simple HTTP server with multiple routes
  • Handled different response types (text and JSON)
  • Tested your server with curl
The server you built uses Ant.serve(), which is powered by libuv for high performance. It automatically handles concurrent requests and includes features like gzip compression for responses over 1KB.
Want to see more examples? Check out the HTTP Server Guide for routing patterns, async handlers, and state management.

Build docs developers (and LLMs) love