# Nextjs-auth0: protect all pages

**URL:** <https://community.auth0.com/t/nextjs-auth0-protect-all-pages/74771>\
**Category:** Get Help\
**Tags:** nextjs\
**Created:** [December 13, 2021, 9:53pm UTC](https://community.auth0.com/t/nextjs-auth0-protect-all-pages/74771 "2021-12-13T21:53:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenriques](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chenriques/32/33734_2.png) [@chenriques](https://community.auth0.com/u/chenriques)\
**Post date:** [December 13, 2021, 9:53pm UTC](https://community.auth0.com/t/nextjs-auth0-protect-all-pages/74771/1 "2021-12-13T21:53:52Z")

</div>

- **Which SDK this is regarding:** nextjs-auth0
- **SDK Version:** 1.6.1
- **Platform Version:** NextJS 12.0.7

Hi,

Following Auth0 SDK docs we can protect each NextJS page by wrapping them with the withPageAuthRequired, like this:

```auto
// pages/profile.js
import { withPageAuthRequired } from '@auth0/nextjs-auth0';

export default withPageAuthRequired(function Profile({ user }) {
  return <div>Hello {user.name}</div>;
});

```

Is there a way to protect all the pages at once instead of using the withPageAuthRequired on each page?

---

<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:** [December 17, 2021, 9:21pm UTC](https://community.auth0.com/t/nextjs-auth0-protect-all-pages/74771/3 "2021-12-17T21:21:00Z")

</div>

Hi @chenriques,

Welcome to the Auth0 Community!

> [@chenriques](#):
>
> Is there a way to protect all the pages at once instead of using the withPageAuthRequired on each page?

Unfortunately, it’s not possible. After checking the Auth0 Next.js SDK, I found that there isn’t an alternative way to wrap authentication to all your pages.

Given that, you’ll need to continue using the _withPageAuthRequired_ to protect the pages you need with authentication.

I hope this helps!

Please let me know if you have any further questions.

Thank you.

---

<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:** [January 1, 2022, 9:21pm UTC](https://community.auth0.com/t/nextjs-auth0-protect-all-pages/74771/4 "2022-01-01T21:21:41Z")

</div>

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