Skip to content

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

ModuleDescription
envEnvironment variables: require, get, has
resultResult type, ok(), err(), defineError()
schemaRuntime type validation with type inference
pinGPIO: digital read/write, analog read
pwmPulse-width modulation
neopixelWS2812 / SK6812 addressable LEDs
i2cI2C bus communication
spiSPI bus communication
uartUART serial communication
wifiWiFi station and access point
bleBLE broadcaster and GATT peripheral
http/requestHTTP client
udpUDP datagram sockets (IPv4 and IPv6)
sleepDelays, deep sleep, light sleep, wakeup sources
sntpNetwork time synchronization
kvKey-value storage (RTC memory + NVS flash)
fsFilesystem I/O with streaming reads
cborCBOR binary encoding and decoding
sysMemory, uptime, GC, restart, environment
testOn-device test framework: describe, test, assert