Skip to main content

useSignInEmailPassword()

Overload 1 of 2

Email and Password Sign-In

Parameters


This overload doesn't accept any arguments.

Examples

const {
signInEmailPassword,
isLoading,
needsEmailVerification,
needsMfaOtp,
sendMfaOtp,
isSuccess,
isError,
error,
user
} = useSignInEmailPassword()
import { useState } from 'react'
import { useSignInEmailPassword } from '@nhost/react'

const Component = () => {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const {
signInEmailPassword,
isLoading,
isSuccess,
needsEmailVerification,
isError,
error
} = useSignInEmailPassword()

return (
<div>
<input
value={email}
onChange={(event) => setEmail(event.target.value)}
placeholder="Email"
/>
<input
value={password}
onChange={(event) => setPassword(event.target.value)}
placeholder="Password"
/>
<button onClick={() => signInEmailPassword(email, password)}>
Register
</button>
{isSuccess && <div>Authentication suceeded</div>}
{needsEmailVerification && (
<div>
You must verify your email to sign in. Check your mailbox and follow
the instructions to verify your email.
</div>
)}
</div>
)
}

Overload 2 of 2

Email and Password Sign-In

Parameters


email optional string


password optional string


otp optional string


Examples

const {
signInEmailPassword,
isLoading,
needsEmailVerification,
needsMfaOtp,
sendMfaOtp,
isSuccess,
isError,
error,
user
} = useSignInEmailPassword()
import { useState } from 'react'
import { useSignInEmailPassword } from '@nhost/react'

const Component = () => {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const {
signInEmailPassword,
isLoading,
isSuccess,
needsEmailVerification,
isError,
error
} = useSignInEmailPassword()

return (
<div>
<input
value={email}
onChange={(event) => setEmail(event.target.value)}
placeholder="Email"
/>
<input
value={password}
onChange={(event) => setPassword(event.target.value)}
placeholder="Password"
/>
<button onClick={() => signInEmailPassword(email, password)}>
Register
</button>
{isSuccess && <div>Authentication suceeded</div>}
{needsEmailVerification && (
<div>
You must verify your email to sign in. Check your mailbox and follow
the instructions to verify your email.
</div>
)}
</div>
)
}