NextJSNetflix/pages/index.tsx

30 lines
655 B
TypeScript

import useCurrentUser from "@/hooks/useCurrentUser"
import { NextPageContext } from "next"
import { signOut,getSession } from "next-auth/react"
export async function getServerSideProps(context: NextPageContext){
const session = await getSession(context)
if(!session){
return {
redirect: {
destination: '/auth',
permanent: false,
},
}
}
return {
props: {}
}
}
export default function Home() {
const { data: user } = useCurrentUser();
return (
<>
<h1 className='text-2xl'>Netflix Clone</h1>
<button onClick={() => signOut()} className="h-10 w-full bg-white">Logout</button>
</>
)
}