You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`isLoading`|`boolean`| Whether initial auth state is loading |
434
+
|`isAuthenticated`|`boolean`| Whether user is authenticated |
435
+
|`isRefreshing`|`boolean`| Whether a token refresh is in progress |
436
+
|`getAccessToken`|`() => Promise<string>`| Get a guaranteed-fresh access token. Throws if not authenticated or refresh fails. |
437
+
|`getUser`|`(forceRefresh?: boolean) => Promise<User \| null>`| Get user function for wallet integration |
438
+
439
+
#### Why no `accessToken` on `session`?
440
+
441
+
The `session` object intentionally does **not** expose `accessToken`. This is a deliberate design choice to prevent consumers from accidentally using a stale/expired token.
442
+
443
+
**Always use `getAccessToken()`** to obtain a token for authenticated requests:
444
+
445
+
```tsx
446
+
// ✅ Correct - always fresh
447
+
const token =awaitgetAccessToken();
448
+
awaitauthenticatedGet("/api/data", token);
449
+
450
+
// ❌ Incorrect - session.accessToken does not exist on the type
{ refreshInterval: 10000 }, // polls every 10s, always gets a fresh token
551
+
);
552
+
}
553
+
```
554
+
468
555
#### The `getUser` Function
469
556
470
557
The `getUser` function returns fresh tokens from the session. It accepts an optional `forceRefresh` parameter:
@@ -489,11 +576,11 @@ When `forceRefresh` is `true`:
489
576
490
577
### ImmutableSession
491
578
492
-
The session type returned by `useImmutableSession`:
579
+
The session type returned by `useImmutableSession`. Note that `accessToken` is intentionally **not** included -- use `getAccessToken()` instead to obtain a guaranteed-fresh token.
493
580
494
581
```typescript
495
582
interfaceImmutableSession {
496
-
accessToken:string;
583
+
//accessToken is NOT exposed -- use getAccessToken() instead
497
584
refreshToken?:string;
498
585
idToken?:string;
499
586
accessTokenExpires:number;
@@ -568,17 +655,19 @@ interface LogoutConfig {
568
655
569
656
The session may contain an `error` field indicating authentication issues:
0 commit comments