React & React NativeHooksAuthenticationuseSignInWithEmailAndPassword

useSignInWithEmailAndPassword

Overview

The useSignInWithEmailAndPassword hook allows users to securely sign in with their email and password. This hook integrates with Replyke’s authentication system and returns access token, refresh token, and user details upon successful registration.

Usage Example

import { useSignInWithEmailAndPassword } from "@replyke/react-js";
 
function SignInForm() {
  const signIn = useSignInWithEmailAndPassword();
 
  const handleSignIn = async () => {
    try {
      const result = await signIn({
        email: "[email protected]",
        password: "securePassword123",
      });
 
      console.log("User signed in:", result.user);
    } catch (error) {
      console.error("Sign-in failed:", error.message);
    }
  };
 
  return <button onClick={handleSignIn}>Sign In</button>;
}

Parameters & Returns

Parameters

The hook returns a function that accepts an object with the following fields:

ParameterTypeRequiredDescription
emailstringYesThe user’s email address.
passwordstringYesThe user’s password.

Returns

The returned function resolves with an object containing:

PropertyTypeDescription
accessTokenstringThe access token for the authenticated user. It should be stored in memory.
refreshTokenstringThe refresh token for the user session. React Native apps must store this securely, whereas React apps do not need to store it manually as it is managed via cookies.
userobjectThe authenticated user’s details.