# The ReferenceError: React is not defined error when using @auth0/nextjs-auth0/server

**URL:** <https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [September 19, 2025, 9:56am UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124 "2025-09-19T09:56:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![BohdanYavorskyi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bohdanyavorskyi/32/60840_2.png) [@BohdanYavorskyi](https://community.auth0.com/u/BohdanYavorskyi)\
**Post date:** [September 19, 2025, 9:56am UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124/1 "2025-09-19T09:56:03Z")

</div>

Hi everyone!

I’m currently trying to migrate my nextjs app to v4 of @auth0/nextjs-auth0 package. I went through all docs, examples, and I already stuck on the first step when simply using auth0 client instance in middleware. I’m getting `React not defined error` and could not find any similar topics. I’m importing the Auth0Client class from /server path (which should not use any React imo) and getting the error.

I’m using Pages router and nextjs version is 14.2.32.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [September 19, 2025, 3:04pm UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124/3 "2025-09-19T15:04:49Z")

</div>

Hi @BohdanYavorskyi

Welcome back to the Auth0 Community!

Can you try adding `import React from 'react'` inside the page component where this error is being thrown?

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![BohdanYavorskyi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bohdanyavorskyi/32/60840_2.png) [@BohdanYavorskyi](https://community.auth0.com/u/BohdanYavorskyi)\
**Post date:** [September 19, 2025, 3:26pm UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124/4 "2025-09-19T15:26:02Z")

</div>

Sure, it’s the first thing I tried. Nothing helped 🙂

It seems it happens due to some react imports in /server output, idk ☹

---

<div class="post-metadata">

**Author:** ![BohdanYavorskyi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bohdanyavorskyi/32/60840_2.png) [@BohdanYavorskyi](https://community.auth0.com/u/BohdanYavorskyi)\
**Post date:** [September 19, 2025, 3:28pm UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124/5 "2025-09-19T15:28:22Z")

</div>

Besides, could I reach you in some chat about how refresh token flow is really working and how it’s handled in the package?

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [September 19, 2025, 3:41pm UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124/6 "2025-09-19T15:41:38Z")

</div>

I see, indeed, most probably it is caused by some react imports or version issues, this can be quite hard to troubleshoot without taking a look at the code itself. I would recommend to [open an issue](https://github.com/auth0/nextjs-auth0/issues) on the SDK’s Github page in order to post the errors received and go through the code to troubleshoot it.

Otherwise, refresh tokens behaviour and handling is explained in the EXAMPLES.MD file of the SDK, you check it out on the Github Documentation [here](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#getting-an-access-token), if you have any further questions regarding the matter, you can post them here or as you have mentioned, feel free to send me a DM if that is more comfortable with you!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [September 22, 2025, 3:16pm UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124/7 "2025-09-22T15:16:28Z")

</div>

Hi again!

As far as I can see from the issue you have opened, a [bug fix](https://github.com/auth0/nextjs-auth0/pull/2329) has been opened regarding the error that you are receiving!

If you still experience issues after this is rolled out, I would recommend to continue the discussion on the opened issue!

Kind Regards,  
Nik

---

<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:** [October 6, 2025, 3:17pm UTC](https://community.auth0.com/t/the-referenceerror-react-is-not-defined-error-when-using-auth0-nextjs-auth0-server/192124/8 "2025-10-06T15:17:02Z")

</div>

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