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
| Module | Description |
|---|---|
| result | Result type, ok(), err(), defineError() |
| pin | GPIO: digital read/write, analog read |
| pwm | Pulse-width modulation |
| neopixel | WS2812 / SK6812 addressable LED strips |
| i2c | I2C bus communication |
| spi | SPI bus communication |
| wifi | WiFi station and access point |
| fetch | HTTP client (fetch API) |
| sleep | Delays, deep sleep, light sleep, wakeup sources |
| sntp | Network time synchronization |
| rtc | Persistent RTC memory (survives deep sleep) |
| sys | Memory, uptime, GC, restart, environment |