You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auth-test.tsx 783B

123456789101112131415161718192021222324252627282930
  1. import Head from 'next/head'
  2. import { signIn, signOut, getSession, useSession } from 'next-auth/client'
  3. import { GetServerSidePropsContext } from 'next'
  4. export default function Home({ session }: any) {
  5. // const [session, loading] = useSession()
  6. return (
  7. <>
  8. <Head>
  9. <title>tldraw</title>
  10. </Head>
  11. <div>
  12. <button onClick={() => signIn()}>Sign In</button>
  13. <button onClick={() => signOut()}>Sign Out</button>
  14. <pre>{JSON.stringify(session, null, 2)}</pre>
  15. {session && <p>Hey, you made it! Thanks for sponsoring me.</p>}
  16. </div>
  17. </>
  18. )
  19. }
  20. export async function getServerSideProps(context: GetServerSidePropsContext) {
  21. const session = await getSession(context)
  22. return {
  23. props: {
  24. session,
  25. },
  26. }
  27. }