Skip to content

mikrojs/mikro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

303 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Mikro.js logo

Mikro.js

TypeScript-first runtime for microcontrollers with a focus on developer experience and iteration speed.

Documentation · Getting Started · API Reference · Examples

Open on npmx.dev Open on npmx.dev Open on npmx.dev

Note

Mikro.js is in early development. Expect APIs to change.

Features

  • Fast feedback loop: interactive dev console with watch mode and incremental builds that deploy to your device in a few seconds
  • Full TypeScript: near-complete ES2024 support, type-checked hardware APIs, and editor autocomplete
  • Batteries included: GPIO, PWM, I2C, SPI, UART, WiFi, HTTP, UDP, NeoPixel, deep sleep, SNTP, CBOR, schema validation, key-value storage, and more
  • Host simulator: run your code on your computer with mikro sim dev. No microcontroller needed
  • No exceptions: typed Result errors instead of try/catch. Every failure is visible in the type signature
  • Built-in testing: test suites with resource leak detection and more. Run in the simulator or on a real device

Quickstart

npm create mikro

Example

import {digitalWrite, pinMode} from 'mikro/pin'
import {sleep} from 'mikro/sleep'

const LED = 20

pinMode(LED, 'OUTPUT').orPanic('Failed to set pin mode')

while (true) {
  digitalWrite(LED, 1)
  await sleep(500)
  digitalWrite(LED, 0)
  await sleep(500)
}

Overview

The core runtime is a standalone C++ library with no ESP-IDF dependencies, making it portable across platforms.

  • Engine: QuickJS-NG (near-complete ES2024 coverage)
  • Runtime: Standalone C++ library with cooperative, single-threaded event loop
  • Platform: ESP-IDF >= 6.0.1 (ESP32, ESP32-C3, ESP32-S3, ESP32-C5, ESP32-C6), desktop (macOS, Linux)
  • Modules: Four-source resolution: virtual modules, native C modules, bytecode builtins, filesystem (LittleFS)
  • Bytecode: TypeScript bundled with esbuild, compiled to QuickJS bytecode at build time
  • Tooling: Node.js CLI (Ink/React), Node-API addon for host-side development and simulation

Acknowledgements

Mikro.js has drawn heavy inspiration from txiki.js, a small JavaScript runtime built on QuickJS.

Thanks to Felix Wieland (@flexwie) for generously donating the mikro package name on npm.

License

MIT