import { useContext } from 'react'; import { User } from '@auth0/auth0-spa-js'; import Auth0Context, { Auth0ContextInterface } from './auth0-context'; /** * ```js * const { * // Auth state: * error, * isAuthenticated, * isLoading, * user, * // Auth methods: * getAccessTokenSilently, * getAccessTokenWithPopup, * getIdTokenClaims, * loginWithCustomTokenExchange, * exchangeToken, // deprecated - use loginWithCustomTokenExchange * loginWithRedirect, * loginWithPopup, * logout, * } = useAuth0(); * ``` * * Use the `useAuth0` hook in your components to access the auth state and methods. * * TUser is an optional type param to provide a type to the `user` field. */ const useAuth0 = ( context = Auth0Context ): Auth0ContextInterface => useContext(context) as Auth0ContextInterface; export default useAuth0;