Created
December 28, 2021 15:57
-
-
Save skolhustick/f077e78a19162b18867a096ea0d8e694 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react' | |
import { signIn } from 'next-auth/react' | |
const Login = () => { | |
const [email, setEmail] = useState('') | |
const sendLoginVerification = e => { | |
e.preventDefault() | |
// Notice, we are also redirecting users to the protected route instead of the homepage after signing in. | |
signIn('email', { callbackUrl: '/protected', email }) | |
} | |
return ( | |
<div> | |
<h1>Login</h1> | |
<h3> | |
Enter your email address, and we will send you a verification link. | |
</h3> | |
<form onSubmit={sendLoginVerification}> | |
<input | |
type='email' | |
value={email} | |
required | |
onChange={e => setEmail(e.target.value)} | |
/> | |
<button type='submit'>Send Magic Link 🪄</button> | |
</form> | |
</div> | |
) | |
} | |
export default Login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment