MCPcopy
hub / github.com/nextauthjs/next-auth / Header

Function Header

apps/dev/components/header.js:8–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6// component that works on pages which support both client and server side
7// rendering, and avoids any flash incorrect content on initial page load.
8export default function Header() {
9 const { data: session, status } = useSession()
10
11 return (
12 <header>
13 <noscript>
14 <style>{".nojs-show { opacity: 1; top: 0; }"}</style>
15 </noscript>
16 <div className={styles.signedInStatus}>
17 <p
18 className={`nojs-show ${
19 !session && status === "loading" ? styles.loading : styles.loaded
20 }`}
21 >
22 {!session && (
23 <>
24 <span className={styles.notSignedInText}>
25 You are not signed in
26 </span>
27 <a
28 href="/api/auth/signin"
29 className={styles.buttonPrimary}
30 onClick={(e) => {
31 e.preventDefault()
32 signIn()
33 }}
34 >
35 Sign in
36 </a>
37 </>
38 )}
39 {session && (
40 <>
41 {session.user.image && (
42 <img src={session.user.image} className={styles.avatar} />
43 )}
44 <span className={styles.signedInText}>
45 <small>Signed in as</small>
46 <br />
47 <strong>{session.user.email} </strong>
48 {session.user.name ? `(${session.user.name})` : null}
49 </span>
50 <a
51 href="/api/auth/signout"
52 className={styles.button}
53 onClick={(e) => {
54 e.preventDefault()
55 signOut()
56 }}
57 >
58 Sign out
59 </a>
60 </>
61 )}
62 </p>
63 </div>
64 <nav>
65 <ul className={styles.navItems}>

Callers

nothing calls this directly

Calls 1

useSessionFunction · 0.90

Tested by

no test coverage detected