© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
매튜

Get user server-side on supabase js 2.0 + next.js

export const getServerSideProps = withPageAuth({
  redirectTo: '/',
  async getServerSideProps(ctx, supabase) {
    //const { user } = await getUser(ctx);
    // Find out how many words user is currently studying at novice level - maximum allowed is 200
    const { data } = await supabase
      .from('users_vocabulary')
      .select('*', { count: 'exact' })
      //.eq('B', user.id);
    return { props: { data } };
  }
});
export const getServerSideProps = withPageAuth({
  redirectTo: '/',
  async getServerSideProps(ctx, supabase) {
    //const { user } = await getUser(ctx);
    // Find out how many words user is currently studying at novice level - maximum allowed is 200
    const { data } = await supabase
      .from('users_vocabulary')
      .select('*', { count: 'exact' })
      //.eq('B', user.id);
    return { props: { data } };
  }
});

The above code worked on the old version of supabase js, but I had to comment out the user selection to make it work on the new version. What is the new equivalent of
const { user } = await getUser(ctx);
const { user } = await getUser(ctx);
?
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

Get user.id server-side in Next.js
SupabaseSSupabase / help-and-questions
4y ago
How to get current user data server side (next.js middleware)
SupabaseSSupabase / help-and-questions
4y ago
Reset user password Flutter / Next.js / Supabase
SupabaseSSupabase / help-and-questions
13mo ago
Next.js getServerSideProps broken after supabase.js 2.0 and auth helpers update
SupabaseSSupabase / help-and-questions
4y ago