# TypeError: “secret” is required

**URL:** <https://community.auth0.com/t/typeerror-secret-is-required/139046>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [July 16, 2024, 2:17pm UTC](https://community.auth0.com/t/typeerror-secret-is-required/139046 "2024-07-16T14:17:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![startup](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@startup](https://community.auth0.com/u/startup)\
**Post date:** [July 16, 2024, 2:17pm UTC](https://community.auth0.com/t/typeerror-secret-is-required/139046/1 "2024-07-16T14:17:33Z")

</div>

I am following the **Add Login to Your Next.js Application** instructions, and get stuck at step **4: Add the dynamic Route Handler** as I keep getting the following error when testing `route.js`:

```auto
throw new TypeError(error.details[0].message);
              ^
TypeError: "secret" is required

```

Here is my directory structure:

- `project_root_directory/.env.local`
- `project_root_directory/src/pages/api/auth/[auth0]/route.js`)

I test it by adding:  
`console.log("the AUTH0_SECRET env var is set: ", !!process.env.AUTH0_SECRET);`

which always returns:  
`the AUTH0_SECRET env var is set: false`

Also, Next.js has two different routers: the `App Router` and the `Pages Router`, and we need to get this working with the `Pages Router`. Is there a tutorial on how to achieve these instructions with the `Pages Router`.

I would love some insights on what I am doing wrong.

[Instructions reference](https://auth0.com/docs/quickstart/webapp/nextjs/interactive)

Thank you!

---

<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:** [August 7, 2024, 12:00am UTC](https://community.auth0.com/t/typeerror-secret-is-required/139046/3 "2024-08-07T00:00:37Z")

</div>

Hi @startup,

Welcome to the Auth0 Community!

It seems that the error is indicating that you are missing a secret value. Please ensure that the secret value is set and located in the correct place.

Here is an example of configuring the Page Router, which you can reference:  
[Auth0 Next.js SDK - Page Router setup](https://github.com/auth0/nextjs-auth0?tab=readme-ov-file#page-router)

Let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![startup](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@startup](https://community.auth0.com/u/startup)\
**Post date:** [August 11, 2024, 7:21pm UTC](https://community.auth0.com/t/typeerror-secret-is-required/139046/4 "2024-08-11T19:21:20Z")

</div>

Hi @rueben.tiow ,

Thanks for the article! Long story short, it seems that the issue was actually the version of `'@auth0/nextjs-auth0'`.

Thanks for your help!  
The Startup

---

<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 25, 2024, 7:21pm UTC](https://community.auth0.com/t/typeerror-secret-is-required/139046/5 "2024-08-25T19:21:30Z")

</div>

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