# Auth using express API protected endpoints and NextJS

**URL:** <https://community.auth0.com/t/auth-using-express-api-protected-endpoints-and-nextjs/104579>\
**Category:** Get Help\
**Tags:** custom-database-connections, connections\
**Created:** [April 12, 2023, 11:47pm UTC](https://community.auth0.com/t/auth-using-express-api-protected-endpoints-and-nextjs/104579 "2023-04-12T23:47:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsm](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@itsm](https://community.auth0.com/u/itsm)\
**Post date:** [April 12, 2023, 11:47pm UTC](https://community.auth0.com/t/auth-using-express-api-protected-endpoints-and-nextjs/104579/1 "2023-04-12T23:47:57Z")

</div>

Hi, I’m trying to figure out how to implement a solution where my NextJS app initiates the login through the auth0 login widget, I get a token back from Auth0, and then use that token to access protected API routes on my Node Express back end. Or maybe I’m thinking about this all wrong.

Note, I’m not using NextJS API routes.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 25, 2023, 12:25am UTC](https://community.auth0.com/t/auth-using-express-api-protected-endpoints-and-nextjs/104579/3 "2023-04-25T00:25:28Z")

</div>

Hey there @itsm welcome to the community, and I apologize for the delayed response!

> [@itsm](#):
>
> I get a token back from Auth0, and then use that token to access protected API routes on my Node Express back end. Or maybe I’m thinking about this all wrong.

You’re thinking here makes sense to me 🙂 Your best bet is to use the [express-oauth2-jwt-bearer](https://github.com/auth0/node-oauth2-jwt-bearer/tree/main/packages/express-oauth2-jwt-bearer) library in your Node backend. You can find some helpful examples [here](https://github.com/auth0/node-oauth2-jwt-bearer/blob/main/packages/express-oauth2-jwt-bearer/EXAMPLES.md).

Hope this helps!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 10, 2023, 12:26am UTC](https://community.auth0.com/t/auth-using-express-api-protected-endpoints-and-nextjs/104579/4 "2023-05-10T00:26:09Z")

</div>

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