Serverless-first. Built for cold starts, tight memory, and one binary.Deploy guide →

API overview

Everything below is available with no imports — Fairyfly injects these globals into every script. Bare specifiers still resolve through node_modules for packages (see Packages).

Globals

GlobalWhat it isReference
consoleOutput, colored aliases, time/timeLog/timeEndconsole
setTimeout, clearTimeoutOne-shot timer (max 128 live)Timers
setInterval, clearIntervalRepeating timerTimers
queueMicrotaskRun before the next timer or I/O callbackEvent loop
performanceperformance.now() — monotonic msperformance
URL, URLSearchParamsWHATWG URL parser, query stringsURL
HeadersCase-insensitive header collectionRequest/Response
RequestFetch request objectRequest/Response
ResponseFetch response object + json/redirect/errorRequest/Response
BlobImmutable binary blobBlob/FormData
FormDatamultipart/form-data containerBlob/FormData
TextEncoder, TextDecoderUTF-8 string ↔ bytesText encoding
fetchHTTP client (16 slots, HTTP/1.1)fetch
WebSocketWebSocket client (max 64 sockets)WebSocket
WorkerOS-thread worker (max 8)Worker
httphttp.serve(options, handler)http
udpDatagram sockets (udp.socket, max 64)udp
fsSync + Promise filesystem callsfs
processargv, env, exit, pid, memoryUsage…process
child_processSubprocesses: spawn / exec / execSync (max 8, POSIX)child_process
cryptorandomUUID, getRandomValues, subtle.digestcrypto
btoa, atobBase64 encode / decodecrypto
DatabaseSQLite (Database.open(path))SQLite
sql, SQLPostgres tagged templates + poolPostgres
ffiC-ABI shared libraries (--allow-ffi)FFI
import.meta.urlfile:// URL of the current moduleModules

Timer handles

setTimeout / setInterval return a Timeout object (pass it to clearTimeout / clearInterval, or call its methods):

const t = setTimeout(() => console.log("later"), 5000);
t.unref();      // don't hold the process open
t.refresh();    // restart the countdown
t.hasRef();     // boolean
t.ref();        // hold the process again

Static helpers you'll use constantly

Response.json({ ok: true });              // Response with JSON content-type
Response.redirect("/login");              // 302 status only — no Location header
URL.parse("not a url");                   // null instead of throwing
new URL("/a/b", "https://x.example");     // base resolution
crypto.randomUUID();                      // v4 UUID
Database.open("app.db");                  // SQLite

Full tables: Response statics and Database methods.

Quick reference

Response statics

MethodSignatureDescription
Response.json(value, init?)(any, { status?, headers? }) → ResponseJSON response shortcut
Response.redirect(url, status?)(string, number?) → ResponseRedirect status (default 302) — Known issue: no Location header emitted
Response.error()() → ResponseError response, status 0

Database methods

MethodSignatureDescription
Database.open(path)(string) → DatabaseOpen or create a database
db.exec(sql, params?)(string, Array?) → undefinedOne statement, bound params
db.execNoArgs(sql)(string) → undefinedMulti-statement SQL, no params
db.row(sql, params?)(string, Array?) → object | nullFirst row
db.rows(sql, params?)(string, Array?) → object[]All rows
db.changes()() → numberRows affected by the last write
db.lastInsertRowId()() → numberRowid of the last insert
db.transaction(fn)(Function) → anyAuto-commit / rollback
db.busyTimeout(ms)(number) → undefinedBusy timeout (default 5000)
db.close()() → undefinedClose the handle

sql / SQL methods

MethodSignatureDescription
sql`…`(template) → Promise<rows>Parameterized query
sql.unsafe(str, params?)(string, Array?) → Promise<rows>String-built, still parameterized
sql.connect()() → Promise<rows>Probe the pool — resolves with the SELECT 1 rows
sql.begin()() → Promise<Tx>Transaction on one connection
sql.close()() → undefinedClose the default pool
tx.commit() / tx.rollback()() → Promise<rows>End the transaction (resolves [])
new SQL(dsn)(string) → SQLPool bound to a DSN

Not provided

These common Node/browser globals are absent — with the substitute to use instead:

MissingUse instead
BufferUint8Array / ArrayBuffer
require() / CommonJSimport / export
process.nextTickqueueMicrotask(fn)
setImmediatesetTimeout(fn, 0)
structuredClonebuilt into postMessage; clone by messaging yourself
AbortController / signalnot supported by fetch
addEventListener on WebSocketws.onopen = … style handlers
TextEncoder#encodeIntoencode()
process.stdout.writeconsole.log (goes to stderr)
DOM, windowbackend runtime

Full list with rationale: Compatibility.

See also