Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sundaray
Copy link

@sundaray sundaray commented Dec 28, 2025

This PR replaces 10 separate useState calls inside authkit-provider.tsx with a single discriminated union:

type AuthState =
 | {
     status: 'loading';
   }
 | { status: 'unauthenticated'; data: Omit<NoUserInfo, 'accessToken'> }
 | { status: 'authenticated'; data: Omit<UserInfo, 'accessToken'> };

This brings two benefits to the codebase:

  • Makes it impossible for anyone to unintentionally create an invalid auth state combination (which is possible now).
  • Makes it immediately clear which auth state is being handled at any point in the code.

Note: There are no changes to the public API. All existing tests pass.

@sundaray sundaray requested a review from a team as a code owner December 28, 2025 08:55
@sundaray sundaray requested a review from amygdalama December 28, 2025 08:55
@amygdalama amygdalama requested review from nicknisi and removed request for amygdalama December 29, 2025 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant