# React native + nextjs + auth0

**URL:** <https://community.auth0.com/t/react-native-nextjs-auth0/100945>\
**Category:** Get Help\
**Tags:** platform-infrastructure, general-architecture-question\
**Created:** [February 21, 2023, 3:51pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945 "2023-02-21T15:51:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucas.melo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.melo/32/44806_2.png) [@lucas.melo](https://community.auth0.com/u/lucas.melo)\
**Post date:** [February 21, 2023, 3:51pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/1 "2023-02-21T15:51:37Z")

</div>

Hey there,

Is there a guide to implement auth0 with react-native and a nextjs serverless backend?

thank you!

---

<div class="post-metadata">

**Author:** ![dan-auth0](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan-auth0](https://community.auth0.com/u/dan-auth0)\
**Post date:** [February 22, 2023, 11:57am UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/2 "2023-02-22T11:57:34Z")

</div>

Hello, Lucas! Welcome to the Auth0 Community.

I want to understand your use case better, please.

Are you looking to use Auth0 to secure a React Native client application and then also use Auth0 to secure access to an API that you are creating using Next.js (perhaps also hosting it on Vercel)? Does the Next.js application also have a client component or is it only an API?

Thanks!

---

<div class="post-metadata">

**Author:** ![lucas.melo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.melo/32/44806_2.png) [@lucas.melo](https://community.auth0.com/u/lucas.melo)\
**Post date:** [February 22, 2023, 12:10pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/4 "2023-02-22T12:10:51Z")

</div>

Hey Dan, thanks for reaching out.

Yes, I am looking for a secure api + web + react native authentication with auth0.

Currently, I am adding auth0 to my nextjs (web and api) and the next step would be allow user to also sign in/up using the react native app.

---

<div class="post-metadata">

**Author:** ![dan-auth0](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan-auth0](https://community.auth0.com/u/dan-auth0)\
**Post date:** [February 22, 2023, 12:34pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/5 "2023-02-22T12:34:51Z")

</div>

Awesome! That’s a fun stack. Let me research this scenario and I’ll get back to you as soon as I have an answer.

---

<div class="post-metadata">

**Author:** ![dan-auth0](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan-auth0](https://community.auth0.com/u/dan-auth0)\
**Post date:** [February 22, 2023, 1:04pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/6 "2023-02-22T13:04:40Z")

</div>

I got an answer: The Auth0 Next.js SDK is intended for web login and it uses cookie-based authentication and authorization instead of a token-based approach. Therefore, calling a protected Next.js API from another client is not supported.

---

<div class="post-metadata">

**Author:** ![lucas.melo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.melo/32/44806_2.png) [@lucas.melo](https://community.auth0.com/u/lucas.melo)\
**Post date:** [February 22, 2023, 2:12pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/7 "2023-02-22T14:12:46Z")

</div>

😕

can I share the same user details between the two projects?

---

<div class="post-metadata">

**Author:** ![dan-auth0](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan-auth0](https://community.auth0.com/u/dan-auth0)\
**Post date:** [February 28, 2023, 1:58am UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/8 "2023-02-28T01:58:55Z")

</div>

🤔 What do you mean exactly by user details in this context?

If both applications are registered under the same tenant, every user that logs in to one of your client apps will have the same ID token. Are you looking to share user metadata?

---

<div class="post-metadata">

**Author:** ![lucas.melo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.melo/32/44806_2.png) [@lucas.melo](https://community.auth0.com/u/lucas.melo)\
**Post date:** [February 28, 2023, 10:48am UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/9 "2023-02-28T10:48:30Z")

</div>

okay so I will try to be more clear.

I am trying to figure out how to protect my api and make requests from react native using a nextjs application as server.

So what I tested so far:  
→ Auth0 with nextjs using cookies: All good.  
→ Auth0 withApiAuth to protect routes: All good.  
→ Auth0 withSsr: all good.

So since nextjs and auth0 make use of cookies I created my own validation (protectedRoute()) that implements a jwt verify or withApiAuth from auth0-nextjs lib. The general idea is that I first check if the request is coming from mobile, if so I wanna verify the access\_token from the authorization bearer token and I am struggling to figure this part out. So…

- So far I have the access\_token issued from react native and I need it in my nextjs api route to verify the access\_token get the user details and continue. How can I do that?

---

<div class="post-metadata">

**Author:** ![iamkc](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@iamkc](https://community.auth0.com/u/iamkc)\
**Post date:** [January 5, 2024, 7:43pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/10 "2024-01-05T19:43:03Z")

</div>

Lucas - Just to be clear, you’re using the `nextjs-auth0` SDK library, right? (you refer to `auth-nextjs` in your message above.)  
If that’s the case, I believe it doesn’t support JWT Bearer tokens.  
See this - [Authentication with access token not working · Issue #1266 · auth0/nextjs-auth0 · GitHub](https://github.com/auth0/nextjs-auth0/issues/1266#issuecomment-1607670837)

Is this the scenario you’re trying to attempt?

---

<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:** [November 25, 2024, 6:18pm UTC](https://community.auth0.com/t/react-native-nextjs-auth0/100945/11 "2024-11-25T18:18:10Z")

</div>

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