Skip to main content

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.

useShellAuth returns the current VA authentication state from the shell’s context. It is a convenience wrapper around usePluginContext().auth.

Import

import { useShellAuth } from "@skyvexsoftware/stratos-sdk";

Signature

function useShellAuth(): PluginUIContext["auth"]

Return value

{
  isAuthenticated: boolean;
  token: string | null;
  user: PluginPilotUser | null;
}
FieldTypeDescription
isAuthenticatedbooleantrue when the user is logged in to a VA (via credentials or OAuth).
tokenstring | nullThe current VA auth token, or null when not authenticated.
userPluginPilotUser | nullPilot profile from the VA API, or null when not authenticated.

PluginPilotUser

type PluginPilotUser = {
  dbID: number;
  pilotID: string;
  firstName: string;
  lastName: string;
  email: string;
  rank: string;
  rankLevel: number;
  rankImage: string;
  avatar: string;
};

Usage

import { useShellAuth } from "@skyvexsoftware/stratos-sdk";

export function UserBadge() {
  const { isAuthenticated, user } = useShellAuth();

  if (!isAuthenticated || !user) {
    return <p>Not logged in</p>;
  }

  return (
    <div className="flex items-center gap-3">
      <img src={user.avatar} alt={user.pilotID} className="h-8 w-8 rounded-full" />
      <div>
        <p className="font-medium">{user.firstName} {user.lastName}</p>
        <p className="text-muted-foreground text-sm">{user.pilotID}{user.rank}</p>
      </div>
    </div>
  );
}

Guard pattern

export function ProtectedView() {
  const { isAuthenticated } = useShellAuth();

  if (!isAuthenticated) {
    return <p>Please log in to use this feature.</p>;
  }

  return <MainContent />;
}

Using the token

For calls to the bound airline’s API, prefer useVaApi() over reading token directly. useVaApi returns a pre-configured axios instance that attaches the bearer, sets the airline’s base_url, and refreshes the access token on 401 — none of which useShellAuth does.
import { useVaApi } from "@skyvexsoftware/stratos-sdk";

const va = useVaApi();
const { data } = await va.get("/pireps");
Reach for useShellAuth().token only when you need the raw bearer — for example, when calling a non-VA service that happens to accept the same token, or when integrating with a third-party HTTP client you’ve already configured.

Notes

  • Auth state reflects the user’s VA login session (credentials or OAuth). It is not plugin-specific.
  • Auth state updates reactively when the user logs in or out — no polling or manual refresh is needed.
  • This hook is equivalent to usePluginContext().auth. Use whichever you prefer.