nanoframe
v0.3.0
Published
Electron-like framework using system webviews powered by a Rust core.
Readme
Status: experimental, but usable for prototypes and internal tools.
Highlights
- System webviews (no bundled Chromium)
- Cross‑platform Rust core with prebuilt binaries per OS/arch
- Simple Node/TypeScript API:
app+BrowserWindow - JSON‑RPC transport over stdio (no local servers)
Install
npm install nanoframe
# or
pnpm add nanoframe
# or
yarn add nanoframe
# or
bun add nanoframePeer/runtime requirements:
- Node.js 20+
- Platform core binary (auto-resolved) or local cargo-built
nanoframe-core
Quick usage
import { app, BrowserWindow } from 'nanoframe'
await app.whenReady
const win = await BrowserWindow.create({
title: 'My App',
width: 800,
height: 600,
url: 'https://example.com'
})
await win.openDevTools()API
app: App
whenReady: Promise<void>– resolves when core is reachableon(event, cb)– events:ready,windowAllClosedcreateWindow(options)– convenience wrapper, same asBrowserWindow.createopenDialog(options)– open file/directory dialogsaveDialog(options)– save dialoggetPath(name, appName?)– resolve OS pathsopenExternal(target)– open URL in default handlerwriteClipboardText(text)/readClipboardText()quit()– terminate the child core process
Environment flags:
NANOF_DEV=1– prefer local cargo build during developmentNANOF_FORCE_PLATFORM=1– force platform package binary when available
BrowserWindow
Constructor is internal; use BrowserWindow.create(options).
Options (subset):
title?: stringwidth?: number,height?: numberurl?: string|html?: stringiconPath?: stringresizable?: boolean,alwaysOnTop?: boolean,fullscreen?: booleandecorations?: boolean,center?: booleanpreload?: string(reserved)
Methods:
show(),hide(),close()setIcon(path),setTitle(title)setSize(w, h),getSize()setPosition(x, y),getPosition()center(),focus(),maximize(),minimize(),unminimize()setAlwaysOnTop(bool),setResizable(bool),setFullscreen(bool),isFullscreen()setDecorations(bool),isVisible()eval(code),openDevTools()postMessage(payload)
How binaries are resolved
At runtime, the SDK tries the following in order:
- If
NANOF_DEV=1or a localpackages/nanoframe-corecargo project exists andNANOF_FORCE_PLATFORMis not set, runcargo run --release --bin nanoframe-coreinside that directory. - Otherwise, resolve a platform package (
@nanoframe/core-<platform>-<arch>) and execute the embedded binary. - Fallback: try
nanoframe-coreon PATH.
Example app
See examples/hello-world in the monorepo for an end-to-end minimal setup using TypeScript.
License
ICL – see repository root LICENSE.
