Next-auth v5 config file server code leaks into client components

I'm upgrading a Next 12 pages router codebase into app router incrementally. So I have to use <SessionProvider> and useSession() for some parts to work. I made those work by upgrading next-auth to v5. But that created another problem. Previously, things like singIn() and signOut() were part of the next-auth/react package; but now they're returned and exported from calling NextAuth(). Inside my auth.ts which I used some boilerplate from create-t3-turbo to upgrade, I have some server code. Things like googleapis, db and env. Apparently just because these are imported in the file, using signIn() exposes them to the client bundle and I get errors such as Module not found: Can't resolve 'fs', or on the client: Error: :x: Attempted to access a server-side environment variable on the client. Thanks in advance ♥️ packages: next 14 canary.51, next-auth 5 beta.13, trpc 11
1 Reply
ahkhanjani
ahkhanjaniOP10mo ago
Solved by importing singIn() from next-auth/react like before in /pages
Want results from more Discord servers?
Add your server