Skip to content

Commit

Permalink
improve type safety for useAuth hook with ensureSignedIn (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicknisi authored Jan 31, 2025
1 parent cdfcad2 commit 3a62b12
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/authkit-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP
);
};

export function useAuth(options: {
ensureSignedIn: true;
}): AuthContextType & ({ loading: true; user: User | null } | { loading: false; user: User });
export function useAuth(options?: { ensureSignedIn?: false }): AuthContextType;
export function useAuth({ ensureSignedIn = false }: { ensureSignedIn?: boolean } = {}) {
const context = useContext(AuthContext);

Expand Down

0 comments on commit 3a62b12

Please sign in to comment.