The authentication context:
FederatedListener
: React component that listens for federated sign-in events.userData
: The current user's profile data.providerData
: The list of supported federated login providers.isLoggedIn
: A boolean indicating whether the user is currently signed in.signOut
: Function to sign out the current user.signIn
: Function to sign in the user with a username and password.signInWithRedirect
: Function to sign in the user using a federated login provider.isSignedInFromRedirect
: A boolean indicating whether the user signed in using a federated login provider.redirectTwitterLogin
: Function to redirect the user to Twitter for sign-in.linkFederated
: Function to link a federated login provider to the user's account.unlinkFederated
: Function to unlink a federated login provider from the user's account.getSteamProfile
: Function to retrieve the user's Steam profile.confirmSignIn
: Function to confirm the user's sign-in.resendConfirmationCode
: Function to resend the confirmation code for sign-up.signUp
: Function to sign up a new user.signUpConfirmation
: Function to confirm the user's sign-up.sendForgotPassword
: Function to send a password reset code.passwordReset
: Function to reset the user's password.updateUserAvatar
: Function to update the user's avatar.createUserParent
: Function to create a parent user.refreshLoggedInUser
: Function to refresh the current user's profile data.getUserMetadata
: Function to retrieve the user's metadata.import { PlayMakersProvider, useAuth } from "react-playmakers";
const App: React.FC = () => {
return (
<PlayMakersProvider PROJECT_ID="my-project-id">
<MainApp />
</PlayMakersProvider>
);
};
const MainApp: React.FC = () => {
const { isLoggedIn, signIn, signOut, userData } = useAuth();
return (
<div>
{isLoggedIn ? (
<div>
<p>Welcome, {userData?.username}!</p>
<button onClick={signOut}>Sign Out</button>
</div>
) : (
<button onClick={() => signIn("user@example.com", "password")}>Sign In</button>
)}
</div>
);
};
Generated using TypeDoc
Provides authentication-related functionality. Manages user authentication, sign-in, sign-out, user metadata retrieval, password reset, federated login support, and user profile updates.
This hook interacts with external authentication services (e.g., Cognito) and maintains user session state in local storage.