- {!session && <>
- You are not signed in
-
+ {!session && (
+ <>
+
+ You are not signed in
+
+ {
@@ -27,14 +35,22 @@ export default function Header () {
>
Sign in
- >}
- {session && <>
- {session.user.image && }
-
- Signed in as
- {session.user.email || session.user.name}
+ >
+ )}
+ {session && (
+ <>
+ {session.user.image && (
+
+ )}
+
+ Signed in as
+
+ {session.user.email || session.user.name}
- {
@@ -44,16 +60,42 @@ export default function Header () {
>
Sign out
- >}
+ >
+ )}
{content || "\u00a0"}
) -} \ No newline at end of file +} diff --git a/pages/server.js b/pages/server.js index f5adcee8..711a2481 100644 --- a/pages/server.js +++ b/pages/server.js @@ -1,4 +1,4 @@ -import { useSession, getSession } from 'next-auth/client' +import { useSession, getSession } from 'next-auth/react' import Layout from '../components/layout' export default function Page () { @@ -6,7 +6,8 @@ export default function Page () { // populated on render without needing to go through a loading stage. // This is possible because of the shared context configured in `_app.js` that // is used by `useSession()`. - const [ session, loading ] = useSession() + const { data: session, status } = useSession() + const loading = status === 'loading' return (