# geterverSideProps in NextJS

**URL:** <https://community.auth0.com/t/geterversideprops-in-nextjs/95848>\
**Category:** Get Help\
**Tags:** reports, support-center\
**Created:** [December 6, 2022, 11:43pm UTC](https://community.auth0.com/t/geterversideprops-in-nextjs/95848 "2022-12-06T23:43:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vickstar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vickstar/32/34448_2.png) [@Vickstar](https://community.auth0.com/u/Vickstar)\
**Post date:** [December 6, 2022, 11:43pm UTC](https://community.auth0.com/t/geterversideprops-in-nextjs/95848/1 "2022-12-06T23:43:28Z")

</div>

Hi there, so I’m having a getServerSideProps function in my next.js page that runs asynchronously. Also I want to authenticate the page with auth0, but next.js isn’t letting me have multiple getServerSideProps in the same page, I also tried authenticating it in the pre-existing getServerSideProps and it isn’t working either.

I’ll appreciate any help I can get here

---

<div class="post-metadata">

**Author:** ![pratyush.pandey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pratyush.pandey/32/53671_2.png) [@pratyush.pandey](https://community.auth0.com/u/pratyush.pandey)\
**Post date:** [January 10, 2024, 7:11pm UTC](https://community.auth0.com/t/geterversideprops-in-nextjs/95848/2 "2024-01-10T19:11:13Z")

</div>

It’s important to note that Next.js only allows a single `getServerSideProps` function per page, which can make integrating multiple functionalities, such as authentication with Auth0 and fetching data asynchronously, a bit tricky. However, there are approaches you can take to address this issue. Here’s a general guideline to help you handle authentication with Auth0 while fetching data asynchronously in a Next.js page:

1. **Combine Functionality in a Single `getServerSideProps`** :

2. **Using a Higher-Order Function for Authentication** :

3. **Decoupling Authentication and Data Fetching** :

4. **Leverage Auth0 SDK and Hooks** :

5. **Asynchronous Data Fetching** :

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 18, 2024, 7:22pm UTC](https://community.auth0.com/t/geterversideprops-in-nextjs/95848/3 "2024-12-18T19:22:59Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
