API Reference
Mikro.js provides hardware and system APIs as ES modules. Import them by name:
ts
import {pinMode, digitalWrite} from 'mikrojs/pin'
import {wifi} from 'mikrojs/wifi'
import {request} from 'mikrojs/http/request'Conventions
Result-based errors. Functions that can fail return a Result<T, E> instead of throwing. Check .ok to narrow the type, or call .orPanic() when failure is unrecoverable. See the Error Handling guide for details.
Async operations. Network operations (wifi.connect, request, wifi.scan) return Promise<Result<T, E>>. Use await and then check the result.
Modules
| Module | Description |
|---|---|
| env | Environment variables: require, get, has |
| result | Result type, ok(), err(), defineError() |
| schema | Runtime type validation with type inference |
| pin | GPIO: digital read/write, analog read |
| pwm | Pulse-width modulation |
| neopixel | WS2812 / SK6812 addressable LEDs |
| i2c | I2C bus communication |
| spi | SPI bus communication |
| uart | UART serial communication |
| wifi | WiFi station and access point |
| ble | BLE broadcaster and GATT peripheral |
| http/request | HTTP client |
| udp | UDP datagram sockets (IPv4 and IPv6) |
| sleep | Delays, deep sleep, light sleep, wakeup sources |
| sntp | Network time synchronization |
| kv | Key-value storage (RTC memory + NVS flash) |
| fs | Filesystem I/O with streaming reads |
| cbor | CBOR binary encoding and decoding |
| sys | Memory, uptime, GC, restart, environment |
| test | On-device test framework: describe, test, assert |