패키지 설치
npm install @supabase/auth-helpers-nextjs
npm install @supabase/auth-helpers-react
'use client';
import { ReactNode, useState } from 'react';
// next.13 버전에서 사용
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs';
import { SessionContextProvider } from '@supabase/auth-helpers-react';
import { Database } from '@/types_db';
interface SupabaseProviderProps {
children: ReactNode;
}
function SupabaseProvider({ children }: SupabaseProviderProps) {
const [supabaseClient] = useState(() =>
createClientComponentClient<Database>()
);
return (
<SessionContextProvider supabaseClient={supabaseClient}>
{children}
</SessionContextProvider>
);
}
export default SupabaseProvider;
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang='en'>
<body className={font.className}>
<SupabaseProvider>
<SideBar>{children}</SideBar>
</SupabaseProvider>
</body>
</html>
);
}