---
title: Introduction
url: "https://scriptc.dev/docs"
docs_index: /llms.txt
lastUpdated: 2026-10-18
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

scriptc is a compiler that turns TypeScript and JavaScript into native executables and WebAssembly modules. It uses the types checked by the TypeScript compiler to generate machine code, and the output runs without Node.js installed.

scriptc is experimental. It supports a subset of JavaScript, TypeScript, and the Node.js APIs, and it tells you at build time when a program uses something outside that subset.

## Features

- **Native output.** `scriptc build` produces an executable for macOS, Linux, or Windows, or a WebAssembly module.
- **Standard TypeScript.** Programs are type-checked by the TypeScript compiler using your `tsconfig.json`. No annotations or language extensions are required.
- **npm dependencies.** Packages your program imports compile to native code together with your own code.
- **Coverage reports.** [`scriptc coverage`](/docs/coverage) shows what compiles and explains anything that doesn't, with a diagnostic code, a source location, and usually a rewrite hint.

## What you can build

- Command-line tools and scripts.
- HTTP and TCP servers built on `node:http`, `node:net`, and TLS, and clients that use `fetch`.
- Parallel programs with [worker threads](/docs/threads).
- [WebAssembly modules](/docs/wasm) that a web or native application calls.
- [Static libraries](/docs/platforms#ios-and-android-arm64-library-mode) for iOS and Android apps, and programs that [call C libraries](/docs/ffi).

## Compile a program

Create a TypeScript file:

```ts title="fib.ts"
function fib(n: number): number {
  return n < 2 ? n : fib(n - 1) + fib(n - 2);
}
console.log(fib(30));
```

`scriptc run` compiles the file and runs the result:

```console
$ scriptc run fib.ts
832040
```

`scriptc build` writes an executable:

```console
$ scriptc build fib.ts -o fib >/dev/null
$ ./fib
832040
```

The [Quickstart](/docs/quickstart) covers installation and a first build.

<span id="compilation-modes" />

## How it works

scriptc type-checks your program with TypeScript, uses the checked types to choose a native representation for every value, and generates machine code with LLVM. The executable links a native runtime that provides memory management, the event loop, and the Node.js APIs your program uses. [How It Works](/docs/how-it-works) describes each stage.

## Language and API support

scriptc compiles supported forms of:

- Classes, inheritance, closures, generics, discriminated unions, destructuring, and spread.
- `async`/`await`, promises, exceptions, iterators, and resource disposal.
- Strings, BigInts, arrays, Maps, Sets, JSON, Math, typed arrays, and Buffers.
- Node.js filesystem, path, process, child-process, crypto, timer, and networking APIs.

Programs are checked against the `es2025` standard library, scriptc's own declarations, and your project's declarations such as `@types/node`. The [Node.js compatibility reference](/compatibility) lists API-level support, and [Limitations](/docs/limitations) describes the remaining restrictions and the places where compiled programs behave differently from Node.js.

## Runtime type checks

Compiled code relies on types, so scriptc checks a value whose type is only known at runtime before using it as a specific type. For example, parsed JSON must match the type you cast it to:

```ts title="cast.ts"
type Config = { port: number };

try {
  const config = JSON.parse('{"port": "eighty"}') as Config;
  console.log(config.port);
} catch (error) {
  if (error instanceof Error) console.log(error.message);
}
```

```console
$ scriptc run cast.ts
expected number at $.port, got string
```

Under Node.js, the same `as Config` assertion performs no check. See [runtime type checks](/docs/limitations#runtime-type-checks) for details.

## Build-time evaluation

`comptime(() => ...)` runs a function while the program compiles and embeds its result as a constant:

```ts title="label.ts"
const label = comptime(() => "hello".toUpperCase());
console.log(label);
```

```console
$ scriptc run label.ts
HELLO
```

## Next steps

- [Quickstart](/docs/quickstart): install scriptc and build your first executable.
- [Coverage Reports](/docs/coverage): check whether an existing program compiles.
- [npm Dependencies](/docs/dependencies): use packages in compiled programs.
- [Platform Support](/docs/platforms): build for other operating systems and WebAssembly.
- [CLI Reference](/docs/cli): every command and option.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)