Getting Started

Embed Linux in your app with a zero-dependency TypeScript SDK.

The unkernel package runs the same kernel file in Node and in every supported browser. It is MIT-licensed, and there is no closed engine or license key behind it, so you can ship it in your product and host it wherever you like.

#Install

npm i unkernel

unkernel needs Node 24+ or a browser with JSPI (Chrome / Edge 137+, Firefox 153+, Safari 27+).

#Boot a kernel

boot.mjs
import { createKernel, fetchDistro } from "unkernel";

const vm = await createKernel({ distro: await fetchDistro("alpine") }); // Alpine, no network
vm.onOutput((bytes) => process.stdout.write(bytes));
vm.write("uname -a; poweroff\n");

const { code, kind } = await vm.exited; // 0, "halt"

Importing unkernel picks the Node or browser entry automatically, and unkernel/node or unkernel/web selects one explicitly. The kernel ships in the package (unkernel/unkernel.wasm) and loads from next to the entry, streamed and compiled while it downloads.

It carries a small base system that mounts a distro image read-only under an overlay root and runs its init. createKernel() without distro boots the base shell (busybox and unkernel's tools), which needs no download.

#Distro images

The distro images are not in the package.

fetchDistro("alpine") (or "debian") downloads one once from the GitHub release of the package's version, checks it against the release's distros.json (size and SHA-256), keeps it in ~/.cache/unkernel (UNKERNEL_CACHE_DIR) and returns its path. Nothing else in the SDK downloads anything.

import { createKernel, fetchDistro } from "unkernel";

const vm = await createKernel({ distro: await fetchDistro("debian") });

Host the image yourself (it is read lazily with range requests) and pass its URL:

import { createKernel } from "unkernel";

const vm = await createKernel({ distro: "/distros/alpine.erofs" });

Changes to the root file system stay in memory, unless a persistent data disk (labelled kwdata) is attached: then each distro keeps them in /data/distros/<name>/ on it. See Disks.

#Next steps