NextJSNetflix/pages/index.tsx

37 lines
830 B
TypeScript

import Billboard from "@/components/Billboard"
import MovieList from "@/components/MovieList"
import Navbar from "@/components/Navbar"
import useCurrentUser from "@/hooks/useCurrentUser"
import useMoviesList from "@/hooks/useMoviesList"
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: film = [] } = useMoviesList();
return (
<>
<Navbar />
<Billboard />
<div className="pb-40">
<MovieList title="Popolari" data={film} />
</div>
</>
)
}