Skip to content

The Slice (Nexus-JS) Developer Handbook (v0.15.0)

Welcome to the complete developer handbook for Slice (Nexus-JS) (v0.15.0) - a microVM-grade JavaScript and TypeScript runtime, compiler, HTTP server, and AI sandbox engineered in Rust.

Whether you are building a high-throughput full-stack web service, packaging a CLI tool into a single zero-dependency executable, running 1,000 untrusted customer plugins on a single machine, or executing LLM-generated TypeScript inside an AI coding agent, this handbook walks you through every feature, CLI command, API, security capability, and migration pattern from the perspective of an application developer.


Traditional JavaScript runtimes (Node.js, Deno, and Bun) were built around a single-tenant process model with ambient POSIX permissions and runtime node_modules filesystem traversal:

  • Every cold start pays for hundreds of OS stat()/open() syscalls and JavaScript parsing.
  • Every imported npm package or plugin shares the same mutable Object.prototype and can read ~/.ssh, query cloud metadata (169.254.169.254), or exfiltrate process.env secrets unless you wrap the entire runtime inside heavy Docker containers or 125 ms Firecracker VMs.

Slice replaces that tradeoff with four developer-facing superpowers:

  1. Instant Cold Starts & Precompiled SLICEBC\x01 Packaging (~1 us P50 Isolate / 0 stat() Syscalls):
    • Run .ts, .js, or entire project folders directly (slice run), pack them into a 64-byte aligned BLAKE3 .cas archive with ahead-of-time Precompiled Boa CodeBlock (SLICEBC\x01) bytecode (slice pack), or compile your backend + frontend UI into a single zero-dependency native executable (slice compile). See tests/reports/latest.md for live cold-start and --warm benchmarks across all 33 real-world workloads against Bun, Deno, and Node.js.
  2. True Multi-Tenant MicroVM Security in Microseconds:
    • Every script or HTTP request executes inside a frozen Secure ECMAScript (SES) compartment with explicit Object-Capability (OCap) permissions (allow_read, allow_write, allow_net, allow_exec, allow_env), deterministic CPU instruction fuel limits, byte-level memory cages, a built-in Cloud Metadata SSRF Firewall, and Outbound Egress DLP that blocks raw, Base64, and Base64URL secret leaks.
  3. Full-Stack Web & Edge Server Out of the Box (slice serve):
    • Write standard WinterTC / Cloudflare Workers / Bun / Deno export default { fetch(req, env, ctx) } handlers (Request, Response, Headers, URL, URLSearchParams, URLPattern, ReadableStream, CompressionStream, Intl), stream Server-Sent Events (Response.sse), use the built-in 16-way sharded Slice.kv store, serve static frontend assets (--static=./public) with < 2 us BLAKE3 ETag 304 responses, and hot-swap tenant bundles (--tenant-dir) with zero downtime. See tests/reports/latest.md for verified HTTP/1.1 Keep-Alive throughput benchmarks.
  4. Unified Configuration & AI Agent Primitives:
    • Configure every engine, limit, OCap permission, and server setting declaratively across slice.toml, top-of-file inline directives (// @slice-...), SLICE_* environment variables, and CLI flags (--*).
    • Run unit tests with slice test, where every test() block automatically snapshots (Slice.checkpoint()) and rolls back (Slice.restore()) both the filesystem (node:fs) and Slice.kv in < 5 us.
    • Spawn nested, capability-attenuated sub-sandboxes in tens of microseconds with Slice.evalSandbox() or connect Claude Code / Cursor directly to slice mcp.

Chapter Title & Developer Focus
Chapter 01 Installation, Upgrading, Quickstart, slice.toml & Complete CLI Reference
Install and update Slice on Windows, Linux, macOS, and Docker; scaffold projects with slice init (including --template=sveltekit); master slice.toml, .env Auto-DLP, < 3 ms --watch, slice check, slice repl, slice doctor, and all 14 CLI commands.
Chapter 02 Writing TypeScript & JavaScript for Maximum Performance
Understand how Slice runs your code across Tier-0 Snapshots, Tier-1 Warm Realms (--warm), and Tier-2 Native SIMD Kernels - and how simple TypeScript type annotations (: number, interface) unlock automatic compile-time speedups.
Chapter 03 Bundling Apps (slice pack), Single-File Executables (slice compile) & Bytecode Inspection
Bundle multi-file TypeScript apps and node_modules into .cas archives, embed frontend static assets (--static), ship standalone native binaries (SLICEEXE), and inspect bundles with slice inspect.
Chapter 04 Zero-Trust Security Guide: OCap Permissions, Fuel Limits, SSRF Shield & Egress DLP
Configure allow_read, allow_write, allow_net, allow_exec, and allow_env; cap CPU fuel and memory per tenant; prevent 169.254.169.254 SSRF attacks; and block accidental or malicious secret leaks with --audit-egress and Auto-DLP .env.
Chapter 05 Building Full-Stack Web Apps, APIs, Static Sites & SSE Streams (slice serve)
Build production HTTP services with export default { fetch }, Request/Response/URL/Headers, Slice.kv rate limiters and sessions, --static CDN asset serving, Response.sse streaming, outbound fetch(), and --tenant-dir hot-swapping.
Chapter 06 AI Agents, Nested MicroVM Sandboxes (Slice.evalSandbox), < 5 us Checkpoints & slice mcp
Execute untrusted LLM or user plugin code safely in microseconds, branch and roll back VFS + KV state with Slice.checkpoint() / Slice.restore(), and integrate slice mcp with Claude Code and Cursor.
Chapter 07 Node.js Compatibility (node:*), NPM Packages & Migration Guide (Node / Bun / Deno to Slice)
Complete API reference for node:fs, node:crypto, node:stream, node:http, node:async_hooks, node:zlib, node:worker_threads, node:string_decoder, node:child_process, node:net, node:dgram, node:path, node:buffer, node:url, node:util, node:process, and node:test, plus npm recipes and migration guides from Express/Fastify, Hono, SvelteKit, Bun, and Deno.
Chapter 08 Embedding Slice in Rust Applications & High-Density MicroVM Swarms
Embed slice-engine, slice-cas, slice-sandbox, and slice-io as a library inside your own Rust services to run thousands of isolated tenant scripts in a single process.
Chapter 09 Time-Travel Testing (slice test), Deterministic Replay & Production Benchmarks
Write rock-solid unit and security tests with slice test (expect(...).toViolate(), .toStayWithinFuel(), < 5 us VFS+KV rollbacks), replay bugs with --deterministic, and explore all 33 real-world benchmark applications, frameworks, and case studies.
Compatibility Matrix WinterTC, Node.js (node:*), Buffer & NPM Bundler Compatibility Matrix
Complete reference of supported WinterTC Web APIs, Uint8Array-backed Buffer methods, node:* core modules, and package.json "exports" bundler capabilities.

Choose Your Path: Common Developer Workflows

Section titled “Choose Your Path: Common Developer Workflows”

1. “I want to build and ship a Full-Stack Web App or REST/GraphQL API”

Section titled “1. “I want to build and ship a Full-Stack Web App or REST/GraphQL API””
  1. Scaffold a project: slice init my-web-api (or slice init my-app --template=sveltekit) (Chapter 01)
  2. Write a standard export default { fetch(req, env, ctx) } handler using Request, Response.json(), URL, and Slice.kv (Chapter 05)
  3. Attach your frontend build folder with --static=./public and compile everything into a single binary:
    Terminal window
    slice compile . -o ./my-web-api --static=./public
    (Chapter 03)

2. “I want to run untrusted customer plugins or AI-generated code safely”

Section titled “2. “I want to run untrusted customer plugins or AI-generated code safely””
  1. Use Slice.evalSandbox(untrustedTsCode, { fuel: 250_000, memoryBytes: 1048576, allowRead: ["/tmp/tenant-1"] }) inside TypeScript (Chapter 06)
  2. Take a < 5 us snapshot before running candidate code (const snap = Slice.checkpoint()) and roll back (Slice.restore(snap)) if the code fails or violates policy (Chapter 06)
  3. Or wire slice mcp directly into your MCP client (mcp.json) so your AI coding assistant can evaluate TypeScript and manage state snapshots over stdio (Chapter 06)

3. “I want to migrate an existing Node.js, Bun, or Deno project to Slice”

Section titled “3. “I want to migrate an existing Node.js, Bun, or Deno project to Slice””
  1. Point slice run or slice test directly at your existing project folder (package.json + src/index.ts + node_modules/) (Chapter 07)
  2. Add a slice.toml manifest with env_file = ".env" and explicit allow_read, allow_write, and allow_net rules so your app is protected by default against SSRF and secret exfiltration (Chapter 04)
  3. Convert tests to slice test (import { describe, test, expect } from "slice:test") to get automatic < 5 us filesystem and KV rollback after every test (Chapter 09)

Documentation Index, Developer Guides (docs/guides/) & System Architecture (docs/system/)

Section titled “Documentation Index, Developer Guides (docs/guides/) & System Architecture (docs/system/)”