Next.js Discord

Discord Forum

Error migrating to template app with auth and use client

Unanswered
Mark posted this in #help-forum
Open in Discord
Hello,
I am currently facing an issue with migration to a template application (https://github.com/vercel/nextjs-postgres-auth-starter), i made a small app to act as a suggestion, tip or feature "jar" but just now wanted to add auth. my app utilizes "use client" "useState" and "useEffect" however each time i use any of these, i immediately get errors from postgressql (is what i assume) but the actual error points to FS for some reason.

This only happens on pages that are actively being "protected" how do i avoid encountering this issue whilst still maintaining the features of my application?

Do note that even if i did not migrate, i would not be able to re-write the app that has most of it's functions on this app because i utilize client components.

1 Reply

Theoretically i could use a middleware that acts as a server component to do all the AUTH stuff and import a client component but that would very quickly become cluttered and annoying, can i somehow use OOP practices to just have 1 file to handle all of it and pass the session down to the client components that need them?