Hi i'm trying to write a project that written with normal Next JS 13. But i am trying to do this with new experimental app directory. So there is no getServerSideProps and when i try to return redirect object it doesnt work. I also tried it with new data Fetching functions
my page.tsx
'use client'
// ...imports...
async function controlSession(context: NextPageContext) {
const session = await getSession(context);
if(!session) {
return {
redirect: {
destination: "/auth",
permanent: false,
},
};
}
return session;
}
export default function Home(context: NextPageContext) {
controlSession(context)
return (
<main>
<h1 className="text-2xl text-green-500">Netflix Clone</h1>
<button
className="p-2 px-4 rounded-lg bg-blue-500 text-white"
onClick={() => signOut()}
>
Sign Out
</button>
</main>
);
}
The original function