Skip to content
Moku LabsDocs
@moku-labs/system pages

@moku-labs/system

One system API, two runtimes. A missing capability is data, not a throw.

system.mdllms.txt

Overview

@moku-labs/system gives Moku apps system capabilities behind one API: store, tray, notify, clipboard, deep-link, lifecycle, back, haptics and keepAwake. A Tauri provider runs when the native shell is detected, a web provider otherwise. Your code never branches on the runtime.

  • One codebase, web and native. Each capability picks its provider once at startup.
  • A degraded capability is data, never a throw. Every method returns SystemResult<T>: { ok: true, value } or { ok: false, reason }.
  • Zero-leak bundles. Plugins live at subpath exports, and the @tauri-apps/* packages are optional peers loaded only in the native shell.
reasonMeaningWhat to do
unsupportedThe capability does not exist here, for good.Hide the feature.
deniedThe user or platform refused permission.Explain, or ask again on purpose.
unavailableIt cannot work right now.Retry later.
errorThe provider threw; the message is kept.Log it and recover.

Install

bun add @moku-labs/system @moku-labs/core @moku-labs/common

Quick start

store.ts
import { createApp } from "@moku-labs/system";
import { storePlugin } from "@moku-labs/system/store";

const system = createApp({
  plugins: [storePlugin],
  pluginConfigs: { store: { name: "my-app" } }
});

await system.start();

const result = await system.store.get<number>("count");
if (result.ok) {
  console.log(result.value ?? 0, `(from the ${result.provider} provider)`);
} else if (result.reason === "unsupported") {
  // hide the feature: this environment will never support it
} else {
  console.warn(result.reason, result.message);
}

await system.stop();
  1. Plugins come from subpaths, never from the root.

To build the native shell, compose the same capabilities in @moku-labs/native. It generates the Tauri permissions from that list.

Start with Claude

Describe what you want. The conductor picks the packages.

Build a blog with tags and an RSS feed on @moku-labs/web

Add a D1-backed comments API with @moku-labs/worker

Make a couch quiz game: TV shows questions, phones answer

Ship this app to macOS and iOS