
# Getting Started

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

The [`unkernel`](https://www.npmjs.com/package/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

:pm-install{name="unkernel"}

unkernel needs Node 24+ or a browser with [JSPI](https://github.com/WebAssembly/js-promise-integration) (Chrome / Edge 137+, Firefox 153+, Safari 27+).

## Boot a kernel

```js [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.

::tabs
  ::tab{label="Node" icon="i-simple-icons-nodedotjs"}
  `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.

  ```js
  import { createKernel, fetchDistro } from "unkernel";

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

  ::tab{label="Browser" icon="i-ph-browser-duotone"}
  Host the image yourself (it is read lazily with range requests) and pass its URL:

  ```js
  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](/sdk/disks).

## Next steps

::card-group{cols="2"}
  ::card
  ---
  title: Run programs
  icon: ph:terminal-window-duotone
  to: /sdk/programs
  ---
  `exec()` and `spawn()`: programs on pipes or on their own pty.
  ::

  ::card
  ---
  title: Network
  icon: ph:globe-duotone
  to: /sdk/network
  ---
  Reach the internet through host sockets or a Wisp proxy.
  ::

  ::card
  ---
  title: Mount host files
  icon: ph:folder-open-duotone
  to: /sdk/mounts
  ---
  Object trees, `MemoryFs` and host directories, mounted in the guest.
  ::

  ::card
  ---
  title: Display, input and sound
  icon: ph:monitor-duotone
  to: /sdk/display
  ---
  A framebuffer, evdev input and ALSA sound.
  ::
::
