Files
hats-app/app/providers/SessionProvider.tsx
T
2025-12-19 13:57:55 +07:00

59 lines
1.7 KiB
TypeScript

'use client'
import { ReactNode } from 'react';
import { type Session } from 'next-auth';
import { SessionProvider as Provider } from 'next-auth/react'
type Props = {
children: ReactNode,
session: Session | null
basePath?: string
};
// function AppProvider({ children, basePath }: { children: ReactNode, basePath: string }) {
// const data = useSession({
// required: true,
// onUnauthenticated: () => {
// window.location.replace(`${basePath}/auth?error=SessionRequired&callbackUrl=${window.location.href}`)
// }
// })
// // ... custom code
// return (
// <>{children}</>
// )
// }
// const SessionProvider: React.FC<Props> = ({ children, session, basePath }) => {
// return (
// <>
// <Provider session={session}
// /* In case you use a custom path and your app lives at "/cool-app" rather than at the root "/" */
// /* PRODUCTION ONLY REMOVE THIS COMMENT */
// basePath={`${basePath}/api/auth`}
// /* Re-fetch session every 5 minutes => default (0) */
// // refetchInterval={5 * 60}
// /* Re-fetches session when window is focused => default (true), Use this value if not using refresh token */
// // refetchOnWindowFocus={false}
// >
// {/* <AppProvider basePath={basePath!}> */}
// {children}
// {/* </AppProvider> */}
// </Provider>
// </>
// );
// }
const SessionProvider: React.FC<Props> = ({ children, session }) => {
return (
<>
<Provider session={session}>
{children}
</Provider>
</>
);
}
export default SessionProvider;