haseakito / funbase

Next generation creators economy platform website
https://funbase.vercel.app
2 stars 0 forks source link

:ambulance: Hotfix the `Error: React Context is unavailable in Server Components` #17

Closed haseakito closed 10 months ago

haseakito commented 10 months ago

Issue

Failed to compile when using NextAuth directly in the layout.tsx because of the following error.

Error: React Context is unavailable in Server Components

Fix

SessionProvider from next-auth/react only works in client component, not the server component. Therefore, make the AuthProvider with use client on top and import the component inside the layout.tsx