
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
ts-obsidian-plugin
Advanced tools
BOTTOM CHANGELOG LICENSE ROADMAP
A TypeScript base package for Obsidian plugins that provides stable, persistent settings management.
The package includes an abstract base class AbstractObsidianPluginWithSettings, interfaces for persistent data and plugins with settings, and helper functions like deepPurge.
loadSettings, saveSettings, onExternalSettingsChange)loadData and saveDatadeepPurge to recursively clear objects while preserving the referencenpm install ts-obsidian-plugin
# or
pnpm add ts-obsidian-plugin
Note: This package has obsidian as a peer dependency (>= 1.5.0). It must be available in the plugin context.
import { AbstractObsidianPluginWithSettings } from "ts-obsidian-plugin";
interface MyPluginSettings {
optionA: string;
optionB: number;
}
export class MyPlugin extends AbstractObsidianPluginWithSettings<MyPluginSettings> {
public getDefaultSettings(): MyPluginSettings {
return {
optionA: "default",
optionB: 42
};
}
async onload() {
await this.loadSettings();
console.log(this.settings.optionA);
}
async saveCustomSettings() {
this._settings.optionB = 100;
await this.saveSettings();
}
}
const data = await this.loadData();
await this.saveData({ custom: "value" });
The package uses Rollup for bundling and Vitest for testing.
# Build
npm run build
# Run tests
npm run test
# Run tests in watch mode
npm run test:watch
Obsidian does not support loading external npm modules at runtime. All dependencies must be bundled.
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
export default {
input: "src/main.ts",
output: {
file: "dist/main.js",
format: "cjs",
},
plugins: [
resolve(),
typescript(),
],
external: ["obsidian"],
};
An abstract base class for Obsidian plugins with typed and persistent settings.
settings: Readonly<TSettings>getDefaultSettings(): TSettings (abstract)
Returns a fully populated default settings object. Must be implemented by subclasses.
loadSettings(): Promise<void>
Loads persisted settings from disk, merges them with default values, and updates the in-memory settings object. Reference to the settings object remains unchanged.
saveSettings(): Promise<void>
Persists the current in-memory settings to disk using the underlying saveData method.
onExternalSettingsChange(): Promise<void>
Reloads settings in response to external modifications of the data file (e.g., file sync or manual changes).
loadData(): Promise<unknown>
Low-level method to load raw persisted plugin data from disk. Returns the deserialized data.json contents or null/undefined if no data exists.
saveData(data: unknown): Promise<void>
Low-level method to save raw plugin data to disk. Performs no validation or transformation.
ObsidianDataPersistence Defines the low-level contract for plugin data persistence:
loadData(): Promise<unknown> – Load raw persisted plugin data.saveData(data: unknown): Promise<void> – Save raw plugin data.PluginWithSettings
Extends ObsidianDataPersistence and adds a structured settings lifecycle:
settings: Readonly<TSettings> – Read-only access to in-memory settings.getDefaultSettings(): TSettings – Returns default settings.loadSettings(): Promise<void> – Load and merge persisted settings.saveSettings(): Promise<void> – Persist current settings.onExternalSettingsChange(): Promise<void> – Reload settings when external changes are detected.FAQs
Unified abstraction for obsidian plugins
The npm package ts-obsidian-plugin receives a total of 3 weekly downloads. As such, ts-obsidian-plugin popularity was classified as not popular.
We found that ts-obsidian-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.