> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# QuickJS

> Run JavaScript scripts and pipe transforms in both Mirage SDKs.

What to install and a runnable TypeScript example. The settings, how the workspace connects and the notes are on [QuickJS](https://docs.mirage.strukto.ai/home/setup/runtime/quickjs.md), shared by both SDKs.

## Install

Download `qjs-wasi.wasm` from a
[quickjs-ng release](https://github.com/quickjs-ng/quickjs/releases) and
point the runtime's `home`, or `MIRAGE_QUICKJS_HOME`, at its directory.

No package to add: each run executes in a worker. In a browser, `home`
is the URL of the folder holding `qjs-wasi.wasm`, and the page needs the
same [worker setup](https://docs.mirage.strukto.ai/typescript/runtime/pyodide.md#worker-and-browser-setup)
as Pyodide.

QuickJS does not run on Cloudflare Workers: with no worker to stop it,
a script that never calls the host would hold the isolate, as the
[Cloudflare quickstart](https://docs.mirage.strukto.ai/typescript/cloudflare-quickstart.md#run-a-workspace)
describes.

## Usage

Declare an `in_process` machine that runs QuickJS to run `node` on it once its engine is found:

```typescript theme={null}
import { MountMode, RAMVFS, Workspace } from '@struktoai/mirage-node'

const ws = new Workspace(
  { '/data': new RAMVFS() },
  {
    mode: MountMode.EXEC,
    machines: { js: { provider: 'in_process', runtime: 'quickjs', home: '/path/to/quickjs' } },
  },
)
await ws.shell("node -e 'console.log(1 + 1)'")
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.