> For the complete documentation index, see [llms.txt](https://docs.nuclearplayer.com/nuclear/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nuclearplayer.com/nuclear/plugins/getting-started.md).

# Getting started with plugins

Spin up a bare plugin, load it in Nuclear, and poke the Plugin SDK to make sure everything is wired.

{% hint style="info" %}
Plugins are folders on disk with a `package.json` and an entry file. The app loads them at runtime and provides `@nuclearplayer/plugin-sdk` to your code.
{% endhint %}

## Usage

{% tabs %}
{% tab title="1) Folder" %}
Create a folder anywhere on your machine, e.g. `~/nuclear-plugins/hello-plugin`.

Run `npm init` inside.
{% endtab %}

{% tab title="2) package.json" %}

```json
{
  "name": "hello-plugin",
  "version": "0.1.0",
  "description": "Minimal Nuclear plugin",
  "author": "Your Name",
  "main": "index.ts",
  "nuclear": {
    "displayName": "Hello Plugin",
    "categories": ["other"]
  }
}
```

{% endtab %}

{% tab title="3) index.ts" %}

```typescript
const CATEGORY = "Examples";

module.exports = {
  async onLoad(api) {
    await api.Settings.register([
      {
        id: "hello",
        title: "Hello world",
        category: CATEGORY,
        kind: "boolean",
        default: true
      }
    ]);

    const v = await api.Settings.get("hello");
    await api.Settings.set("hello", !v);
  },

  async onEnable(api) {
  api.Settings.subscribe("hello", () => {});
  }
};
```

The app compiles TS on the fly. No additional setup is needed.
{% endtab %}
{% endtabs %}

## Load it in the app

1. Open Nuclear → Preference → Plugins (from the left sidebar).
2. Click Add Plugin and select your plugin folder.
3. Toggle it on. `onLoad` runs at import time; `onEnable` runs when you enable.

## Verify the SDK

* Open Settings and find the "Examples" section. You should see "Hello world" with a toggle.
* Flip it. The value persists to disk and updates subscribers.

{% hint style="warning" %}
Setting IDs are auto-namespaced. Use bare IDs like `hello`; the app stores them as `plugin.<pluginId>.hello`.
{% endhint %}

## Plugin shape

```typescript
type Plugin = {
  onLoad?(api: NuclearPluginAPI): void | Promise<void>;
  onEnable?(api: NuclearPluginAPI): void | Promise<void>;
  onDisable?(api: NuclearPluginAPI): void | Promise<void>;
  onUnload?(api: NuclearPluginAPI): void | Promise<void>;
};
```

`package.json` keys used by the loader:

* `name`, `version`, `description`, `author`
* `main` (optional). If missing, the app tries `index.js`, `index.ts`, `index.tsx`, then `dist/index.*`.
* `nuclear.displayName` (optional UI name)
* `nuclear.categories` (shown in the Plugins list)
* `nuclear.icon` and `nuclear.permissions` (optional; unknown permissions get a warning)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nuclearplayer.com/nuclear/plugins/getting-started.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
