# @mikrojs/native

> Mikro.js C++ runtime library and Node.js native addon

Latest version **0.22.0** (published 2026-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mikrojs/native
pnpm add @mikrojs/native
yarn add @mikrojs/native
bun add @mikrojs/native
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.22.0 |
| Published | 2026-09-30 |
| First published | 2026-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=24.0.0 |
| Dependencies | 4 |
| Unpacked size | 6.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 16 |
| Author | Bjørge Næss <bjoerge@gmail.com> |
| Maintainers | bjoerge |
| Keywords | esp32, mikrojs, native, quickjs, runtime |

## Links

- npm: https://www.npmjs.com/package/@mikrojs/native
- Repository: https://github.com/mikrojs/mikro
- Homepage: https://github.com/mikrojs/mikro#readme
- Issues: https://github.com/mikrojs/mikro/issues
- npm.io page: https://npm.io/package/@mikrojs/native

## Dependencies (4)

- [cmake-js](https://npm.io/package/cmake-js.md) ^8.0.0
- [node-addon-api](https://npm.io/package/node-addon-api.md) ^8.9.2
- [node-gyp-build](https://npm.io/package/node-gyp-build.md) ^4.8.4
- [@mikrojs/quickjs](https://npm.io/package/@mikrojs/quickjs.md) 0.22.0

## Recent versions

- 0.22.0 (latest) — 2026-09-30
- 0.21.1-next.20260928214050 (next) — 2026-09-28
- 0.21.0-pr-431.20260921210123 (pr-431) — 2026-09-21
- 0.19.0-pr-352.20260829215534 (pr-352) — 2026-08-29
- 0.18.0-pr-306.20260731215718 (pr-306) — 2026-07-31
- 0.17.1-pr-300.20260731010039 (pr-300) — 2026-07-31
- 0.17.0-pr-276.20260721233726 (pr-276) — 2026-07-22
- 0.16.1-pr-265.20260718161156 (pr-265) — 2026-07-18
- 0.15.0-pr-243.20260613121220 (pr-243) — 2026-06-13
- 0.14.0-pr-229.20260613004639 (pr-229) — 2026-06-13
- 0.11.0-pr-172.g462f877 (pr-172) — 2026-05-30
- 0.10.0-pr-171.g56c9fcc (pr-171) — 2026-05-30
- 0.10.0-pr-134.gc6ec955 (pr-134) — 2026-05-30
- 0.8.0-pr-133.g02588d5 (pr-133) — 2026-05-21
- 0.8.0-pr-115.g87a99f9 (pr-115) — 2026-05-16
- … 74 more at https://npm.io/package/@mikrojs/native/versions

## README

# @mikrojs/native

Standalone, platform-independent C++ runtime library for Mikro.js, powered by QuickJS-NG. Zero ESP-IDF dependencies. Runs on any POSIX host for development and testing, and on ESP32 via a thin platform adapter.

## Directory structure

```
include/        Public C/C++ headers (mikrojs.h, platform.h, private.h, …)
src/            C/C++ source files (runtime, modules, timers, REPL, …)
runtime/        TypeScript runtime modules bundled to bytecode at build time
addon/          Node-API addon exposing the runtime to Node.js
scripts/        Build scripts (esbuild bundling, qjsc bytecode compilation)
test/           Host-side C++ tests (Unity, run via ctest)
```

## Build

```sh
# Standalone library (host)
cmake -B build && cmake --build build

# Run C++ tests
ctest --test-dir build --output-on-failure

# Node addon
pnpm run build:native
```

## Architecture

The runtime abstracts platform-specific operations via `MIKPlatform` (defined in `include/mikrojs/platform.h`). A default POSIX implementation is provided in `src/platform_posix.cpp`. The ESP32 adapter in `packages/@mikrojs/firmware/components/mikrojs/` supplies an ESP-IDF implementation.

### Runtime modules

TypeScript modules in `runtime/` are the JS-facing APIs (fetch, pin, wifi, etc.). During each CMake build they are:

1. Bundled with esbuild (`scripts/bundle-runtime.js`)
2. Compiled to bytecode with qjsc (`scripts/compile-bytecode.sh`)
3. Included as C headers in `src/builtins.cpp`

Type-checked separately via `tsconfig.runtime.json`:

```sh
tsc --noEmit -p tsconfig.runtime.json
```

### Node addon

The `addon/` directory contains a Node-API binding that wraps the C++ runtime for use from Node.js/TypeScript. See [`addon/README.md`](addon/README.md).

---
_Source: https://npm.io/package/@mikrojs/native · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
