-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (21 loc) · 623 Bytes
/
index.js
File metadata and controls
23 lines (21 loc) · 623 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { signIn, signOut, useSession } from "next-auth/react";
export default function Home() {
// Use the useSession hook to get session data
const { data: session } = useSession();
return (
<div>
{/* Check if we have session data indicating the user is logged in */}
{session ? (
<>
<p>Welcome, {session.user.email}!</p>
<button onClick={() => signOut()}>Sign out</button>
</>
) : (
<>
<p>You are not signed in</p>
<button onClick={() => signIn()}>Sign in</button>
</>
)}
</div>
);
}