Micro — Asynchronous HTTP Microservices

10.0.1 · active · verified Tue Apr 21

Micro is a minimalistic library for creating ultra-lightweight, asynchronous HTTP microservices. It's built around the `async`/`await` pattern, enabling developers to write concise and highly performant request handlers with minimal boilerplate. The current stable version is 10.0.1, which introduced ES Modules support and TypeScript conversion. While it doesn't adhere to a fixed release cadence, updates are released to maintain compatibility with newer Node.js versions and modern JavaScript features. Its core differentiators include a tiny codebase (approximately 260 lines of code), explicit dependency management without implicit middleware, and a design philosophy focused on standard HTTP interactions. It is specifically intended for use within containerized environments, and the project explicitly advises against its use in serverless platforms like Vercel, where platform-native helpers often provide similar or superior functionality.

Common errors

Warnings

Install

Imports

Quickstart

Sets up a basic Micro service that responds to GET requests and parses JSON POST bodies.

import { IncomingMessage, ServerResponse } from 'http';
import { json, send } from 'micro';

interface MyRequestBody {
  name: string;
}

export default async (req: IncomingMessage, res: ServerResponse) => {
  if (req.method === 'POST') {
    const data = (await json(req)) as MyRequestBody;
    return send(res, 200, { message: `Hello, ${data.name}!` });
  } else {
    return 'Welcome to Micro! Send a POST request with JSON { "name": "YourName" }.';
  }
};

view raw JSON →