Skip to main content

@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.

NamespaceWhat it coversReference
editor.onLoad / onDisposeActivation and cleanupLifecycle
editor.commandsRegister, execute and hook commandsCommands, Hooks
editor.windowToasts, input boxes, pickers, status bar, webviews, bottom sheets, popupsWindow & UI API
editor.workspaceProject root, active file, open tabs, theme, configurationFile System API
editor.workspace.fsRead, write, list, copy, move, zip, share filesFile System API
editor.terminalOpen terminals, send input, read outputTerminal API
editor.storageKey-value store, data and cache directoriesStorage API
editor.networkfetch() and WebSockets through the hostNetwork API, WebSocket API
editor.editorDiff editor tabsDiff Editor API
editor.snippetsAdd, list and delete code snippetsSnippets API
editor.formattersRegister code formattersFormatters
editor.extensionsRegister CodeMirror 6 extensionsCodeMirror Extensions
editor.eventsFile, tab, theme and config eventsEvent System
listen / postMessage channels between extension and webviewsMessaging 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.