Documentation Index
Fetch the complete documentation index at: https://docs.skyvexsoftware.com/llms.txt
Use this file to discover all available pages before exploring further.
usePluginContext returns the full PluginUIContext object that the shell injects into every plugin’s React tree via PluginShellProvider. It is the foundational hook — all other shell utility hooks (useShellAuth, useShellToast, etc.) call it internally.
Import
import { usePluginContext } from "@skyvexsoftware/stratos-sdk";
Signature
function usePluginContext(): PluginUIContext
Throws if called outside a PluginShellProvider.
Return value
type PluginUIContext = {
/** The plugin's unique ID */
pluginId: string;
/** VA authentication state */
auth: {
isAuthenticated: boolean;
token: string | null;
user: PluginPilotUser | null;
};
/** Current airline info from the Stratos API (null if not logged in) */
airline?: {
id: string;
name: string;
icao: string;
logo_light: string;
logo_dark: string;
} | null;
/** Synchronous config store, namespaced to this plugin */
config: {
get<T>(key: string): T | undefined;
get<T>(key: string, defaultValue: T): T;
};
/**
* Real-time bridge between this plugin's background and UI modules.
* `on(event, handler)` receives broadcasts the background made via
* `ctx.ipc.send(event, payload)`. Both sides use the leaf event name —
* the shell scopes the channel to your plugin id. `emit` is intentionally
* not implemented; send UI → background traffic through HTTP routes
* registered with `ctx.server.registerRouter`.
*/
socket: {
connected: boolean;
emit(event: string, data: unknown): void;
on(event: string, handler: (data: unknown) => void): void;
off(event: string, handler: (data: unknown) => void): void;
};
/** Navigation helpers */
navigation: PluginNavigationHelper;
/** Toast/notification API */
toast: PluginToastAPI;
/** Scoped logger for renderer-side logging */
logger: PluginLogger;
};
PluginNavigationHelper
type PluginNavigationHelper = {
navigateTo(path: string): void;
navigateToPlugin(pluginId: string, path: string): void;
navigateToShell(path: string): void;
getCurrentPath(): string;
};
PluginToastAPI
type PluginToastAPI = {
success(message: string): void;
error(message: string): void;
info(message: string): void;
warning(message: string): void;
};
PluginLogger
type PluginLogger = {
info(category: string, message: string, ...args: unknown[]): void;
warn(category: string, message: string, ...args: unknown[]): void;
error(category: string, message: string, ...args: unknown[]): void;
debug(category: string, message: string, ...args: unknown[]): void;
};
PluginPilotUser
type PluginPilotUser = {
dbID: number;
pilotID: string;
firstName: string;
lastName: string;
email: string;
rank: string;
rankLevel: number;
rankImage: string;
avatar: string;
};
Usage
import { usePluginContext } from "@skyvexsoftware/stratos-sdk";
export function MyComponent() {
const { auth, airline, toast } = usePluginContext();
return (
<div>
<p>Airline: {airline?.name ?? "Unknown"}</p>
{auth.isAuthenticated && auth.user ? (
<p>Welcome, {auth.user.firstName} {auth.user.lastName}</p>
) : (
<p>Not authenticated</p>
)}
<button onClick={() => toast.success("Saved!")}>Save</button>
</div>
);
}
Notes
- Convenience wrappers like
useShellAuth, useShellToast, etc. are available if you only need a single field from the context. They call usePluginContext() internally.
- The
socket field is the plugin-scoped bridge to your own background module’s ctx.ipc.send broadcasts. For high-frequency simulator data sourced from outside your plugin, use useSimData or useSocket instead.