# Shell

## Shell API for plugins

The Shell API lets plugins use select functions to interact with the user's system. It lets you support OAuth flows where the user needs to approve access on an external site.

{% hint style="info" %}
Access the Shell API via `api.Shell.*` in your plugin's lifecycle hooks.
{% endhint %}

***

## Usage

A typical use case is redirecting the user to an external auth page:

```typescript
import type { NuclearPluginAPI } from '@nuclearplayer/plugin-sdk';

export default {
  async onEnable(api: NuclearPluginAPI) {
    const token = await getAuthToken();
    const authUrl = `https://example.com/auth?token=${token}`;
    await api.Shell.openExternal(authUrl);
  },
};
```

***

## Reference

```typescript
api.Shell.openExternal(url: string): Promise<void>
```

Opens `url` in the user's default system browser. Delegates to Tauri's opener plugin.

### Types

```typescript
type ShellHost = {
  openExternal(url: string): Promise<void>;
};
```


---

# Agent Instructions: 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:

```
GET https://docs.nuclearplayer.com/nuclear/plugins/shell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
