Helper Functions
@mnaoumov/obsidian-lib provides a range of Obsidian-specific helper functions. The general-purpose ones live in @mnaoumov/typescript-lib; see its Getting started guide.
The functions are grouped by files and folders and you have multiple ways to import them. Each of the following is an alternative to the others.
From the module’s own subpath:
import { prompt } from '@mnaoumov/obsidian-lib/modals/prompt';await prompt({ app, title: 'Enter your name'});From the folder’s subpath, where each module is a namespace:
import { prompt } from '@mnaoumov/obsidian-lib/modals';await prompt.prompt({ app, title: 'Enter your name'});From the main entry, where each folder is a namespace:
import { modals } from '@mnaoumov/obsidian-lib';await modals.prompt.prompt({ app, title: 'Enter your name'});As a namespace import of the main entry:
import * as obsidianLib from '@mnaoumov/obsidian-lib';await obsidianLib.modals.prompt.prompt({ app, title: 'Enter your name'});For files/folders that use kebab-case names, namespace-style imports require bracket notation because kebab-case names are not valid JavaScript identifiers:
import * as obsidianLib from '@mnaoumov/obsidian-lib';await obsidianLib['file-manager'].addAlias({ alias: 'new-alias', app, pathOrFile: file, resourceLockComponent: null});Prefer the module subpath. A namespace import from the root loads every module of the library, while a subpath loads only the module it names and what that module imports.
Flat imports via __merged
Section titled “Flat imports via __merged”If you would rather not remember which file a helper lives in, __merged gives you every value export of the library flattened into a single namespace — no deep paths, no nesting. It is a generated barrel of every value export, deduplicated so each name is unique, and it includes the value exports of @mnaoumov/typescript-lib too.
Import the names directly from the @mnaoumov/obsidian-lib/__merged subpath:
import { invokeAsyncSafely, prompt, unique} from '@mnaoumov/obsidian-lib/__merged';
const ids = unique([1, 1, 2]);
await prompt({ app, title: 'Enter your name'});Or pull the whole flat barrel as a single namespace from the main entry:
import { __merged } from '@mnaoumov/obsidian-lib';
const ids = __merged.unique([1, 1, 2]);
await __merged.prompt({ app, title: 'Enter your name'});__merged only contains value exports (functions, classes, constants) — it deliberately omits type-only exports. Where a cross-platform module has desktop- and mobile- twins of the same name, it carries the cross-platform one. It is the same flat surface that backs the lib bag inside evalInObsidian integration-test closures.