> ## Documentation Index
> Fetch the complete documentation index at: https://fairyfly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# fairyfly

fairyfly
is a JavaScript runtime built for instant scale-to-zero and high-density cloud.

Built for cold starts, tight memory, and short-lived handlers. One binary with HTTP, TLS, HTTP/2, WebSocket, fetch, SQLite, Postgres, workers, and FFI.

[Get started](https://fairyfly.dev/getting-started/introduction.md)

[Quickstart](https://fairyfly.dev/getting-started/quickstart.md)

[GitHub](https://github.com/AbdElMajidOuhamane/ff)

![Fairyfly logo](https://mintcdn.com/fairyfly/lKP-5nOUrOLv7Po8/ff-logo.webp?fit=max\&auto=format\&n=lKP-5nOUrOLv7Po8\&q=85\&s=12ae125769b4ea6d634eababdd9bcae5)

```sh Install theme={null}
curl -fsSL https://www.fairyfly.dev/install.sh | sh
```

165k
req/sec

\~10 ms
cold start

2.9 ms
p50

1
binary

> [card] [Built for serverless](https://fairyfly.dev/guides/deploy.md)
>
> Fast cold starts, roughly 5 MB RSS on Apple silicon, and one binary. No npm install for the core.

> [card] [One binary, batteries included](https://fairyfly.dev/api/overview.md)
>
> HTTP, TLS, HTTP/2, WebSocket, fetch, SQLite, Postgres, workers, crypto, and FFI ship in the same binary.

> [card] [Small enough to audit](https://fairyfly.dev/concepts/architecture.md)
>
> About 32k lines of Zig across 73 files. The whole runtime fits in your head.

> [card] [ESM without the baggage](https://fairyfly.dev/guides/packages.md)
>
> Pure-JS ESM packages via ff imprint, one flat node\_modules, and a lockfile with integrity hashes.

> [card] [Predictable limits](https://fairyfly.dev/reference/limitations.md)
>
> Every hard cap is documented — connections, bodies, timers, workers, and fetch slots.

> [card] [Deploy anywhere](https://fairyfly.dev/guides/bytecode.md)
>
> Prebuilt binaries, containers, and bytecode for serverless, edge, and long-lived deployments.

## Built for the shape of serverless.

**Serverless first** — Fairyfly is designed first for short-lived, memory-constrained workloads: fast cold starts, one binary, no npm install for the core, and a process that exits when the event loop drains.

* Start fast: one binary with no runtime dependency tree.
* Stay small: roughly 5 MB RSS for a hello-world server on Apple silicon.
* Exit cleanly: no referenced work means the process stops.

[Serverless deployment guide →](https://fairyfly.dev/guides/deploy.md) · [Read the design deep dive →](https://fairyfly.dev/blog/what-is-fairyfly.md)

```js handler.js theme={null}
const port = Number(process.env.PORT ?? 3000);

http.serve({ port }, (url) => {
  if (url === "/health") return Response.json({ ok: true });
  return new Response("hello from fairyfly");
});
```

```sh theme={null}
ff start --allow-env=PORT --allow-net=0.0.0.0:3000
```

Fairyfly is a native POSIX binary: it fits container-based serverless platforms and edge VMs, not V8-isolate runtimes such as Cloudflare Workers.

## Serve, call, and store — with zero setup.

**Quick start** — No package.json, no node\_modules, no build step for the core. The server, client, and database are already in the binary.

* Start an HTTP server with `http.serve`.
* Call any API with the built-in `fetch`.
* Persist data with embedded SQLite through `Database.open`.

[Read the quickstart →](https://fairyfly.dev/getting-started/quickstart.md)

```js server.js theme={null}
http.serve({ port: 3000 }, (url, method, body, headers) => {
  if (url === "/json") return Response.json({ ok: true });
  if (url === "/echo" && method === "POST") return new Response(body);
  return new Response("not found", { status: 404 });
});
```

```sh theme={null}
ff server.js --allow-net=0.0.0.0:3000
```

## Everything you need is already in the binary.

**Batteries included** — HTTP, WebSocket, fetch, SQLite, Postgres, workers, crypto, and FFI. No dependency tree to install or audit.

> [card] [HTTP server](https://fairyfly.dev/api/http.md)
>
> HTTP/1.1, TLS, HTTP/2, and automatic WebSocket upgrades.

> [card] [fetch](https://fairyfly.dev/api/fetch.md)
>
> 16 concurrent HTTP/1.1 slots, AbortSignal, redirects, proxies, and a 30 s timeout.

> [card] [WebSocket](https://fairyfly.dev/api/websocket.md)
>
> Server upgrades and a client with text and binary frames.

> [card] [SQLite](https://fairyfly.dev/api/sqlite.md)
>
> Embedded, synchronous Database.open() with transactions.

> [card] [Postgres](https://fairyfly.dev/api/postgres.md)
>
> Tagged-template sql queries, TLS verify-full, and a 10-connection pool.

> [card] [Workers](https://fairyfly.dev/api/worker.md)
>
> Up to 8 OS threads with structured-clone messaging.

> [card] [Crypto](https://fairyfly.dev/api/crypto.md)
>
> UUIDs, random values, SHA digests, HMAC, bcrypt, and base64 helpers.

> [card] [FFI](https://fairyfly.dev/api/ffi.md)
>
> Call C-ABI shared libraries with --allow-ffi.

## Small enough to read. Fast enough to ship.

**Architecture** — About 32k lines of Zig across 73 files. One event loop, no hidden request threads, and a hot path designed for the common case.

* 512-slot SoA connection table with packed 2-byte flags.
* 64 KB static response staging per slot, spilling to the heap at 10 MB.
* libxev event loop: io\_uring on Linux, kqueue on macOS, epoll fallback.

1. **JavaScript source**
2. **QuickJS parser + bytecode**
3. **Zig API layer**
4. **libxev · io\_uring / epoll / kqueue**

[How it works →](https://fairyfly.dev/concepts/architecture.md)

## One binary for the whole workflow.

**CLI** — Scaffold, run, test, and ship with the same ff binary. No separate task runner or build tool.

> [card] ff init
>
> Write ff.json and an entry file in one command.
>
> `ff init -y my-app`

> [card] ff start
>
> Run the project's main, with optional TLS cert and key.
>
> `ff start --allow-net=0.0.0.0:3000`

> [card] ff test
>
> Run test/\*.test.js through the runtime.
>
> `ff test`

> [card] ff compile
>
> Ship bytecode with source and debug info stripped.
>
> `ff compile app.js -o app.ffbc`

[Full CLI reference →](https://fairyfly.dev/reference/cli.md)

## Ship it anywhere.

**Deploy** — Ship a prebuilt binary, a container, or bytecode with the source stripped.

> [card] Prebuilt binary
>
> macOS and Linux, installed to \~/.local/bin/ff with a SHA-256 check.
>
> `curl -fsSL https://www.fairyfly.dev/install.sh | sh`

> [card] Docker
>
> A container image with the runtime and tools ready to run.
>
> `docker run --rm ghcr.io/abdelmajidouhamane/ff:latest ff --version`

> [card] Bytecode
>
> Compile to .ffbc with source and debug info stripped.
>
> `ff compile app.js -o app.ffbc`

[Deployment guide →](https://fairyfly.dev/guides/deploy.md) · [Installation →](https://fairyfly.dev/getting-started/installation.md)

## Install packages without the baggage.

**ES modules** — ff imprint installs pure-JS ESM packages, writes a lockfile with integrity hashes, and keeps one flat node\_modules.

* No CommonJS, require(), or node: imports.
* One flat node\_modules — conflicting versions fail loudly.
* Direct GitHub, Codeberg, and tarball sources with integrity pins.

[Package guide →](https://fairyfly.dev/guides/packages.md)

```sh terminal theme={null}
ff imprint marked@18.0.11
# adds marked to ff.json and ff.lock
# materializes node_modules/
# then: import { marked } from "marked";
```

## Start with one binary. Stay small.

**Get started** — Install Fairyfly, run a server, and measure the memory yourself.

```sh theme={null}
curl -fsSL https://www.fairyfly.dev/install.sh | sh
```

[Quickstart](https://fairyfly.dev/getting-started/quickstart.md) · [GitHub](https://github.com/AbdElMajidOuhamane/ff)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.