Skip to main content
useShellAuth returns the current authentication state from the shell’s context. It is a thin wrapper around usePluginContext().auth — calling it is equivalent but more readable in components that only need auth state.

Import

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

Signature

function useShellAuth(): PluginUIContext["auth"]

Return value

{
  isAuthenticated: boolean;
  token: string | null;
  user: unknown;
}
FieldTypeDescription
isAuthenticatedbooleantrue when the user is logged in to the shell’s Stratos account
tokenstring | nullThe current auth token, or null when not authenticated
userunknownUser profile data from the Stratos API. Cast to your VA’s user type.

Usage

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

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

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

  return (
    <div>
      <p>Authenticated</p>
      <pre>{JSON.stringify(user, null, 2)}</pre>
    </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

const { token } = useShellAuth();

const fetchData = async () => {
  if (!token) return;

  const response = await fetch("https://api.my-va.com/pireps", {
    headers: { Authorization: `Bearer ${token}` },
  });
  return response.json();
};

Notes

  • Auth state is provided by the shell and reflects the user’s Stratos login session. It is not plugin-specific.
  • The user field type is unknown because the shell does not enforce a specific user schema. Cast it to your VA’s user type or use a type guard.
  • Auth state updates reactively when the user logs in or out — no polling or manual refresh is needed.