Next.js Discord

Discord Forum

Automatic Server Action on Page?

Unanswered
Vap0r1ze posted this in #help-forum
Open in Discord
I have an auth/popup/page.tsx that I want to immediately call signIn from auth.js (v5)
My problem is that it seems to need to be in a server action, and I cant just call it from useEffect since the page is a server component. Ideally a good solution would call this method during server-side rendering so that this is 1 network call instead of 2 like putting it in a client component would. Any ideas?

4 Replies

Common House-Martin
If you're trying to get the session from a server component you might try to get it from this maybe? https://next-auth.js.org/getting-started/example
im not trying to get a session im trying to trigger a sign-in flow
i have a sign-in button, and that opens a popup to /auth/popup which needs to trigger a signin flow
also keep in mind this is next-auth v5 so their docs are incomplete but located here https://authjs.dev/guides/upgrade-to-v5