Skip to content

Latest commit

 

History

494 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: save a file and the device runs the new code seconds later
  • Full TypeScript: near-complete ES2024, type-checked hardware APIs, editor autocomplete
  • Batteries included: GPIO, PWM, I2C, SPI, UART, WiFi, HTTP, UDP, NeoPixel, deep sleep, SNTP, CBOR, schema validation, key-value storage
  • Host simulator: run your code on your computer with mikro sim dev, no microcontroller attached
  • No exceptions: typed Result errors instead of try/catch, so every expected failure is visible in the signature
  • Built-in testing: test suites with resource leak detection, in the simulator or on real hardware

Quickstart

npm create mikro

Example

import {DigitalOut} from 'mikro/gpio'
import {sleep} from 'mikro/sleep'

const led = DigitalOut(20).orPanic('Failed to configure LED pin')

while (true) {
  led.write(1)
  await sleep(500)
  led.write(0)
  await sleep(500)
}

Overview

The core runtime is a standalone C++ library with no ESP-IDF dependencies. This makes 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.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

About

Run TypeScript on microcontrollers (esp32)

Topics

Resources

Code of conduct

Contributing

Stars

13 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages