nix-wasm Browser Demo

Run ... WASM packages directly in your browser. No server required.

Usage Instructions

Browser Usage

All tools run entirely in your browser using WebAssembly. Click a package to load it, then use the tool sections below.

Cloudflare Workers

import { WASI } from '@cloudflare/workers-wasi';

export default {
  async fetch(request, env) {
    // Fetch WASM module from R2
    const wasmUrl = 'https://pub-7a62d9c6620b4b96ad8e5b6f89745725.r2.dev/jq-1.7.1-wasm32-wasi.wasm';
    const wasmModule = await WebAssembly.compileStreaming(fetch(wasmUrl));

    // Setup WASI with stdin
    const stdin = new TextEncoder().encode('{"name": "test"}');
    const wasi = new WASI({ args: ['jq', '.name'], stdin });

    // Run
    const instance = await WebAssembly.instantiate(wasmModule, {
      wasi_snapshot_preview1: wasi.wasiImport
    });
    await wasi.start(instance);

    return new Response(wasi.getStdoutString());
  }
};

Node.js / Deno

import { WASI } from 'node:wasi';
import { readFile } from 'node:fs/promises';

const wasi = new WASI({
  version: 'preview1',
  args: ['jq', '.name'],
  stdin: 0, stdout: 1, stderr: 2
});

const wasmBuffer = await readFile('./jq.opt.wasm');
const wasmModule = await WebAssembly.compile(wasmBuffer);
const instance = await WebAssembly.instantiate(wasmModule, wasi.getImportObject());
wasi.start(instance);

Browser JavaScript

// Minimal WASI shim for browsers (see source of this page for full implementation)
const registry = await fetch('https://pub-7a62d9c6620b4b96ad8e5b6f89745725.r2.dev/registry.json').then(r => r.json());
const pkg = registry.packages['jq'];
const wasmBytes = await fetch(pkg.versions[pkg.latest].url).then(r => r.arrayBuffer());
const module = await WebAssembly.compile(wasmBytes);

// Instantiate with WASI imports
const wasi = new BrowserWASI({ args: ['jq', '.name'], stdin: '{"name": "test"}' });
const instance = await WebAssembly.instantiate(module, { wasi_snapshot_preview1: wasi.exports });
wasi.setMemory(instance.exports.memory);
instance.exports._start();
console.log(wasi.getOutput()); // "test"

Registry API

// Fetch package registry
const registry = await fetch('https://pub-7a62d9c6620b4b96ad8e5b6f89745725.r2.dev/registry.json').then(r => r.json());

// Get package info
const pkg = registry.packages['jq'];
console.log(pkg.latest);                        // "1.7.1"
console.log(pkg.versions['1.7.1'].url);         // WASM URL
console.log(pkg.versions['1.7.1'].hash);        // SHA-256 for verification
console.log(pkg.versions['1.7.1'].size);        // Size in bytes

GitHub Repository · Documentation

Package Registry

JSON
Nix
Text
Data
Utils
Shell
SSH

jq - JSON Processor

Click a package above to load it, then run

sqlite3 - SQL Database

Output will appear here...

nix eval - Expression Evaluator

Output will appear here...

nix-hash - Content Hashing

Output will appear here...

sed - Stream Editor

Output will appear here...

grep - Pattern Matching

Output will appear here...

sort - Sort Lines

Output will appear here...

tr - Character Translation

Output will appear here...

base64 - Encode/Decode

Output will appear here...

xxd - Hex Dump

Output will appear here...

gzip - Compression

Output will appear here...

sha256sum / sha512sum

Output will appear here...

wc - Word Count

Output will appear here...

head / tail

Output will appear here...

cat - Concatenate

Output will appear here...

cowsay

Output will appear here...

Run Any Package

Select a package and run

SSH Terminal

Connect to SSH servers via WebSocket proxy. Note: Cannot connect to hosts behind Cloudflare (like terminal.shop). See docs.