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 {fetch} from 'mikrojs/fetch'

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, fetch, wifi.scan) return Promise<Result<T, E>>. Use await and then check the result.

Modules

ModuleDescription
resultResult type, ok(), err(), defineError()
pinGPIO: digital read/write, analog read
pwmPulse-width modulation
neopixelWS2812 / SK6812 addressable LED strips
i2cI2C bus communication
spiSPI bus communication
wifiWiFi station and access point
fetchHTTP client (fetch API)
sleepDelays, deep sleep, light sleep, wakeup sources
sntpNetwork time synchronization
rtcPersistent RTC memory (survives deep sleep)
sysMemory, uptime, GC, restart, environment