Wi-Fi
For networking to work on a device, it needs Wi-Fi. Kog handles this two ways: credentials baked in at flash time (the usual case — the app just works), or connecting from code at runtime.
On the desktop simulator and web playground there's no radio, so WiFi is
always-connected emulation — fetch/WebSocket work and WiFi.status()
reports connected. You only think about Wi-Fi for real devices.
This playground runs the emulation, so WiFi.status() reports connected with a
synthetic IP (on a device it would reflect the real association):
The easy path: provision at flash time
Put your network in kog.config:
export default defineConfig({
network: {
wifi: {
ssid: 'my-network',
password: '${WIFI_PASSWORD}', // resolved from your environment
autoConnect: true, // join at boot, before your app runs
},
},
});
Then bake the credentials onto the board with the CLI:
WIFI_PASSWORD='hunter2' kog wifi
kog wifi writes the credentials to the device's kog_net NVS partition at
flash time — not into your app bundle. With autoConnect: true, the device
joins the network at boot, so fetch works from the first line of your app.
kog wifi --print-csv shows exactly what will be written without touching
anything; kog wifi --ssid X --pass Y provisions without editing the config.
Keep secrets out of git
Your Wi-Fi password is a secret — never commit it. Kog supports:
- Environment references:
password: '${WIFI_PASSWORD}'(orprocess.env.WIFI_PASSWORDin a TS/JS config) is resolved at provision time. Keep the value in a gitignored.envor your shell. - A literal password in your config draws a warning — you'll see it every
time you run
kog wifi.
New projects already .gitignore .env and *.local.
Connecting from code
Call WiFi.connect() at runtime — for a setup screen, a network picker, or to
switch networks:
// Join the credentials you provisioned with `kog wifi`:
await WiFi.connect();
// Or join a specific network:
const conn = await WiFi.connect('guest-network', 'password');
console.log('got IP', conn.ip);
Pass { save: true } to persist the credentials on a successful join (off by
default, so a retry loop can't wear out the flash):
await WiFi.connect(ssid, password, { save: true });
Status and events
const status = WiFi.status(); // { state, ssid?, ip?, rssi?, mac? }
if (WiFi.isConnected) { /* ... */ }
await WiFi.ready(); // resolves when connected
const off = WiFi.on('disconnect', (s) => showBanner('Wi-Fi lost'));
WiFi.scan() returns nearby networks on a device (a fixed synthetic list on the
sim/playground). A join failure rejects with a KogNetError — NET_AUTH for a
wrong password, NET_WIFI for other failures.
Provisioning from the browser flasher
The docs "Run on device" panel can flash a board over Web Serial, but it does
not provision Wi-Fi yet — that's a roadmap item. Use
the CLI (kog wifi) to bake credentials; the browser flasher handles the app
image.
See the API reference for the full WiFi surface,
and kog wifi for all the command's flags.