# How to use Auth0 Provider with the new react router v6 createBrowserRouter instead of BrowserRouter?

**URL:** <https://community.auth0.com/t/how-to-use-auth0-provider-with-the-new-react-router-v6-createbrowserrouter-instead-of-browserrouter/91121>\
**Category:** Get Help\
**Created:** [September 22, 2022, 10:22am UTC](https://community.auth0.com/t/how-to-use-auth0-provider-with-the-new-react-router-v6-createbrowserrouter-instead-of-browserrouter/91121 "2022-09-22T10:22:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorgosera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/giorgosera/32/39490_2.png) [@giorgosera](https://community.auth0.com/u/giorgosera)\
**Post date:** [September 22, 2022, 10:22am UTC](https://community.auth0.com/t/how-to-use-auth0-provider-with-the-new-react-router-v6-createbrowserrouter-instead-of-browserrouter/91121/1 "2022-09-22T10:22:39Z")

</div>

Hi there,

We’re migrating to v6.4 and using the new createBrowserRouter instead of BrowserRouter. Specifically we’re using `createRoutesFromElements` as suggested by the docs to migrate our routes to the new `createBrowserRouter` router.

Our setup looks something like this

```auto
const router = createBrowserRouter(
  createRoutesFromElements(--> our routes go here <--)
);

root.render(
  <React.StrictMode>
    <ChakraProvider theme={theme}>
      <RouterProvider router={router} />
    </ChakraProvider>
  </React.StrictMode>
);

```

Auth0 docs say that the Auth0 provider should be nested under the provider. How could this be done with the new router?

We’ve tried wrapping the Auth provider around the Routes in `createRoutesFromElements` but doesn’t work. Also tried to do this but we get an error.

```auto
<RouterProvider router={router} >
    <Auth0Provider />
</RouterProvider>

```

Can someone please help me understand where to place the Auth0 provider? Thank you 🙏

---

<div class="post-metadata">

**Author:** ![juan.calle](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/juan.calle/32/40333_2.png) [@juan.calle](https://community.auth0.com/u/juan.calle)\
**Post date:** [September 29, 2022, 9:09pm UTC](https://community.auth0.com/t/how-to-use-auth0-provider-with-the-new-react-router-v6-createbrowserrouter-instead-of-browserrouter/91121/2 "2022-09-29T21:09:58Z")

</div>

I’m encountering the same blocker. It’d be great to hear back from the team at Auth0!

---

<div class="post-metadata">

**Author:** ![giorgosera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/giorgosera/32/39490_2.png) [@giorgosera](https://community.auth0.com/u/giorgosera)\
**Post date:** [October 4, 2022, 4:53pm UTC](https://community.auth0.com/t/how-to-use-auth0-provider-with-the-new-react-router-v6-createbrowserrouter-instead-of-browserrouter/91121/3 "2022-10-04T16:53:32Z")

</div>

For anyone else who might stumble upon this in the future here’s what worked for me: [reactjs - How to use Auth0 provider with the new createBrowsereRouter in v6.4? - Stack Overflow](https://stackoverflow.com/questions/73934043/how-to-use-auth0-provider-with-the-new-createbrowsererouter-in-v6-4/73938067?noredirect=1#comment130573558_73938067)

cc: @juan.calle hope it helps you too

---

<div class="post-metadata">

**Author:** ![juan.calle](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/juan.calle/32/40333_2.png) [@juan.calle](https://community.auth0.com/u/juan.calle)\
**Post date:** [October 10, 2022, 10:06am UTC](https://community.auth0.com/t/how-to-use-auth0-provider-with-the-new-react-router-v6-createbrowserrouter-instead-of-browserrouter/91121/4 "2022-10-10T10:06:48Z")

</div>

Trhanks for this [giorgosera](https://community.auth0.com/u/giorgosera)

---

<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:** [July 3, 2024, 9:07pm UTC](https://community.auth0.com/t/how-to-use-auth0-provider-with-the-new-react-router-v6-createbrowserrouter-instead-of-browserrouter/91121/5 "2024-07-03T21:07:58Z")

</div>

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