Installing the API Types
The Obsidian API package provides TypeScript type definitions that you’ll use when building your plugin.The
obsidian package should be installed as a dev dependency since it only provides type definitions. The actual Obsidian runtime will be available when your plugin runs inside the app.Package Details
The package includes:- Version: 1.12.3 (follows Obsidian’s release cycle)
- Main Types:
obsidian.d.ts - Dependencies:
@types/codemirror- CodeMirror 5 typesmoment- Date/time library types
- Peer Dependencies:
@codemirror/state(6.5.0) - CodeMirror 6 state@codemirror/view(6.38.6) - CodeMirror 6 view
Using the Sample Plugin Template
The easiest way to start building a plugin is to use the official sample plugin template:Sample Plugin Template
The official template includes TypeScript, esbuild configuration, and example code to get you started quickly.
Setting Up From Scratch
If you prefer to set up your project manually:TypeScript Configuration
Key TypeScript settings for Obsidian plugins:target: UseES2021or later for modern JavaScript featuresmodule: Set toESNextfor ES module syntaxlib: IncludeES2021andDOMfor standard APIsmoduleResolution: Usenodefor npm package resolutionstrict: Enable strict type checking (recommended)
Build Configuration
You’ll need a bundler to package your plugin. The sample plugin template uses esbuild for fast builds:The
obsidian package must be marked as external in your bundler config since it’s provided by the Obsidian app at runtime.File Structure
A typical plugin project structure:Next Steps
Now that you have the API types installed, you’re ready to build your first plugin!Quickstart Guide
Follow our step-by-step guide to create a working plugin with commands and UI elements.