@srcnexus/ext-sdk
@srcnexus/ext-sdk is the SDK every SrcNexus Code Editor extension is written against. It is published on npm as @srcnexus/ext-sdk and ships full TypeScript type definitions.
Install
npm install @srcnexus/ext-sdk
Requires Node.js 14 or later to build. Projects created with @srcnexus/create-extension already have it as a dependency.
Quick start
import editor from "@srcnexus/ext-sdk";
editor.onLoad(() => {
editor.commands.registerCommand("myExt.greet", async () => {
const name = await editor.window.showInputBox({ prompt: "Your name:" });
if (name) editor.window.showToast(`Hello, ${name}!`);
});
});
editor.onDispose(() => {
// cleanup
});
Named imports work too:
import { commands, window as win, workspace } from "@srcnexus/ext-sdk";
API map
Each namespace has a dedicated reference page with full signatures and examples.
| Namespace | What it covers | Reference |
|---|---|---|
editor.onLoad / onDispose | Activation and cleanup | Lifecycle |
editor.commands | Register, execute and hook commands | Commands, Hooks |
editor.window | Toasts, input boxes, pickers, status bar, webviews, bottom sheets, popups | Window & UI API |
editor.workspace | Project root, active file, open tabs, theme, configuration | File System API |
editor.workspace.fs | Read, write, list, copy, move, zip, share files | File System API |
editor.terminal | Open terminals, send input, read output | Terminal API |
editor.storage | Key-value store, data and cache directories | Storage API |
editor.network | fetch() and WebSockets through the host | Network API, WebSocket API |
editor.editor | Diff editor tabs | Diff Editor API |
editor.snippets | Add, list and delete code snippets | Snippets API |
editor.formatters | Register code formatters | Formatters |
editor.extensions | Register CodeMirror 6 extensions | CodeMirror Extensions |
editor.events | File, tab, theme and config events | Event System |
listen / post | Message channels between extension and webviews | Messaging API |
Permissions
Extensions declare what they need in manifest.json. Available permissions: fs, terminal, network, storage, projectCreate. See Permissions.
Runtime notes
Extension code runs in an embedded JavaScript engine — not a browser and not Node.js. The DOM, localStorage, and Node built-ins are unavailable; use the SDK equivalents instead. See Getting Started → The extension runtime for the full list of what is and is not available.
Related
- Extensions — Getting Started
@srcnexus/create-extension— scaffold a project that uses this SDKsrcnexusCLI — deploy your extension- All npm packages