> ## 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

> Access VA authentication state from the shell.

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

## Import

```ts theme={null}
import { useShellAuth } from "@skyvexsoftware/stratos-sdk";
```

## Signature

```ts theme={null}
function useShellAuth(): PluginUIContext["auth"]
```

## Return value

```ts theme={null}
{
  isAuthenticated: boolean;
  token: string | null;
  user: PluginPilotUser | null;
}
```

| Field             | Type                      | Description                                                           |
| ----------------- | ------------------------- | --------------------------------------------------------------------- |
| `isAuthenticated` | `boolean`                 | `true` when the user is logged in to a VA (via credentials or OAuth). |
| `token`           | `string \| null`          | The current VA auth token, or `null` when not authenticated.          |
| `user`            | `PluginPilotUser \| null` | Pilot profile from the VA API, or `null` when not authenticated.      |

### `PluginPilotUser`

See [`PluginPilotUser`](/sdk/type-reference#pluginpilotuser) for the full shape.

## Usage

```tsx theme={null}
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

```tsx theme={null}
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()`](/sdk/hooks/use-va-api)** 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.

```tsx theme={null}
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.
