# Auth0 with NextJS problem

**URL:** <https://community.auth0.com/t/auth0-with-nextjs-problem/111916>\
**Category:** Get Help\
**Created:** [July 22, 2023, 12:05pm UTC](https://community.auth0.com/t/auth0-with-nextjs-problem/111916 "2023-07-22T12:05:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![haitham](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@haitham](https://community.auth0.com/u/haitham)\
**Post date:** [July 22, 2023, 12:05pm UTC](https://community.auth0.com/t/auth0-with-nextjs-problem/111916/1 "2023-07-22T12:05:58Z")

</div>

Hello All,  
I am new to Software engineering and development. I am trying to implement auth0 for out application which is using nextjs for frontend and springboot for backend. I successfully implemented the auth0 login in nextjs. I am using the App route structure, so I had to create a new folder named “pages” to be able to follow the instruction provided in auth0. I am not very confident about this procedure but I got it to work.

I still need to to the following:  
1- secure nextjs pages (only authenticated user could access otherwise redirect to login page)  
2-secure endpoints in java (spring boot)  
4-send secure calls from nextjs to the backend APIs.

I am a little bit lost on how to protect pages in nextjs. I know I need to use “withPageAuthRequired” but looks like it is not working only with Page router not the app router.

I am experiencing a lot of deprecated functions and issues that are related to using App router in nextjs and using ‘org.springframework.boot’ version ‘3.0.6’ in the backend.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [July 24, 2023, 3:44pm UTC](https://community.auth0.com/t/auth0-with-nextjs-problem/111916/3 "2023-07-24T15:44:17Z")

</div>

Hi @haitham,

Thanks for reaching out to the Auth0 Community!

To secure your web pages, I recommend implementing [Role-Based Access Control](https://auth0.com/docs/manage-users/access-control/rbac) to leverage scopes (permissions) to grant users access to selective pages.

Our [Node.js API Implementation (SPAs + API)](https://auth0.com/docs/get-started/architecture-scenarios/spa-api/api-implementation-nodejs) documentation covers in more detail how to secure your API endpoints.

I hope this helps!

Please reach out if you need additional clarification or have any questions.

Thanks,  
Rueben

---

<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:** [August 7, 2023, 3:45pm UTC](https://community.auth0.com/t/auth0-with-nextjs-problem/111916/4 "2023-08-07T15:45:14Z")

</div>

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