The current code I have is below, which follows the tutorials for Next.js per page getLayout (see TypeScript section) and NextAuth with TypeScript (or should I say, tries to follow...):
import "../styles/globals.css";
import type { AppProps } from "next/app";
import { SessionProvider } from "next-auth/react";
import { Session } from "next-auth";
import Header from "components/Header";
import { ReactElement, ReactNode } from "react";
import { NextPage } from "next";
type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
getLayout?: (page: ReactElement) => ReactNode;
};
type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
};
function MyApp({ Component, pageProps }: AppPropsWithLayout) {
const getLayout = Component.getLayout || ((page: any) => page);
return getLayout(
<SessionProvider session={pageProps.session}>
<Header />
<Component {...pageProps} />
</SessionProvider>
);
}
export default MyApp;
I keep getting the error Property 'session' does not exist on type '{}'.ts
on pageProps.session
. What do I need to change the TypeScript to, to make this work?