NarraLeaf

Main

Electron main-process runtime, configuration, windows, user events, hooks, and storage.

The Main module is the Electron main-process surface of NarraLeaf. It creates the application host, launches the main window, wires the renderer event bridge, manages app data paths, and exposes save and JSON storage helpers.

import { AppConfig } from "narraleaf";

const app = new AppConfig().create();

app.onReady(() => {
    void app.launchApp();
});

Entry Points

The same stable surface is available from narraleaf and narraleaf/main.

import {
    App,
    AppConfig,
    AppWindow,
    assertSafeStorageKey,
} from "narraleaf";

Guides

User-Facing Exports

  • App: Electron application host.
  • AppConfig: chainable configuration builder that creates App.
  • AppWindow: BrowserWindow wrapper returned by app.launchApp().
  • StoreProvider: type for custom save backends.
  • assertSafeStorageKey, MAX_STORAGE_KEY_LENGTH: validation helpers for save ids and JSON store names.

Main Events

For app-level renderer-to-main calls, register handlers with AppWindow.handleUserEvent() and call them from the renderer with requestMain() or invokeMainEvent().

Low-Level Contract Types

The package also exports low-level IPC contract types such as IPCEventType, Namespace, IPCEvents, and RequestStatus. They describe NarraLeaf's built-in preload bridge and default handlers. Most applications should not import them for ordinary app features.

On this page