© 2026 Hedgehog Software, LLC

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

redux-next-wrapper with supabase v2 ssr

Before supabase V2 I got my data and stored in with redux like this:

supabase V2 broke unfortunately some functionality with redux-next-wrapper


export const getServerSideProps = wrapper.getServerSideProps(
  (store) => async ({ req }) => {
    const { user } = await supabase.auth.api.getUserByCookie(req);
    if (user === null) {
      return {
        redirect: {
          permanent: false,
          destination: "/auth",
        },
        props: {},
      };
    }
    if (user) {
      async function getData() {
        let { data, error, status } = await supabase
          .from("table")
          .select(
export const getServerSideProps = wrapper.getServerSideProps(
  (store) => async ({ req }) => {
    const { user } = await supabase.auth.api.getUserByCookie(req);
    if (user === null) {
      return {
        redirect: {
          permanent: false,
          destination: "/auth",
        },
        props: {},
      };
    }
    if (user) {
      async function getData() {
        let { data, error, status } = await supabase
          .from("table")
          .select(
id
)
          .eq("id", user.id);
        store.dispatch(writeUserData(data));
        return data;
      }

      return {
        props: {
          data: await getData(),
        },
      };
    }
  }
);
)
          .eq("id", user.id);
        store.dispatch(writeUserData(data));
        return data;
      }

      return {
        props: {
          data: await getData(),
        },
      };
    }
  }
);


Any ideas how I can achieve the same functionality with withPageAuth()?

export const getServerSideProps = withPageAuth({
  redirectTo: '/foo',
  async getServerSideProps (ctx, supabase) {
    // Access the user object
    const {
      data: { user }
    } = await supabase.auth.getUser()

    return { props: { id: user?.id } }
  }
})
export const getServerSideProps = withPageAuth({
  redirectTo: '/foo',
  async getServerSideProps (ctx, supabase) {
    // Access the user object
    const {
      data: { user }
    } = await supabase.auth.getUser()

    return { props: { id: user?.id } }
  }
})
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

NextJs Supabase SSR rate limit with cache wrapper...
SupabaseSSupabase / help-and-questions
3y ago
Rate limiting with Supabase + Next.js SSR
SupabaseSSupabase / help-and-questions
2mo ago
Next.js and Supabase v2
SupabaseSSupabase / help-and-questions
4y ago
session with @supabase/ssr
SupabaseSSupabase / help-and-questions
3y ago