© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
4 replies
Waldo

NextJs SSR `withPageAuth` from `supabaseauth-helpers-nextjs` doesn't pick up the authenticated user

This is a NextJs project.

If I have this button handler code on my SignIn page:

 const { error } = await supabase.auth.signIn(
      { email },
      {
        redirectTo: 
 const { error } = await supabase.auth.signIn(
      { email },
      {
        redirectTo: 
http://localhost:3000/user/asd`,
}
)


Then I click on my email the 'magic link', and then

When my protected page 


Then I click on my email the 'magic link', and then

When my protected page 
pages/user/[id].js
 attempts to get the already authenticated user with this

 attempts to get the already authenticated user with this

export const getServerSideProps = withPageAuth({
redirectTo: '/auth/sign_in_or_create_account',
async getServerSideProps(ctx) {
const { user } = await getUser(ctx)
return { props: { user: user } }
},
})


I'm redirected back to login page when I should stay at 


I'm redirected back to login page when I should stay at 
/user/[id]` route.

How does the server side page can 'know' that the user already clicked the magic link from the email?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

withPageAuth user undefined for authenticated user
SupabaseSSupabase / help-and-questions
4y ago
'supabaseauth-helpers-nextjs' gives SyntaxError Unexpected token 'export'
SupabaseSSupabase / help-and-questions
4y ago
supabaseauth-helpers-nextjs has no exported member named createMiddlewareSupabaseClient
SupabaseSSupabase / help-and-questions
4y ago
Next.js, user doesn't get authenticated
SupabaseSSupabase / help-and-questions
4y ago