# Auth0, React and Single-Spa - \[You forgot to wrap your component in \<Auth0Provider\>\]

**URL:** <https://community.auth0.com/t/auth0-react-and-single-spa-you-forgot-to-wrap-your-component-in-auth0provider/77731>\
**Category:** Get Help\
**Tags:** spa, react, auth0\
**Created:** [February 5, 2022, 3:13am UTC](https://community.auth0.com/t/auth0-react-and-single-spa-you-forgot-to-wrap-your-component-in-auth0provider/77731 "2022-02-05T03:13:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![natasha-b](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/natasha-b/32/34987_2.png) [@natasha-b](https://community.auth0.com/u/natasha-b)\
**Post date:** [February 5, 2022, 3:13am UTC](https://community.auth0.com/t/auth0-react-and-single-spa-you-forgot-to-wrap-your-component-in-auth0provider/77731/1 "2022-02-05T03:13:13Z")

</div>

I am creating an app using Single-Spa, React and Auth0. The auth0/auth0-react documentation specifies to wrap the app in the following way:

```auto
  <Auth0Provider
    domain="YOUR_AUTH0_DOMAIN"
    clientId="YOUR_AUTH0_CLIENT_ID"
    redirectUri={window.location.origin}
  >
    <App />
  </Auth0Provider>

```

However with Single-Spa the components are mounted and un-mounted based on the url path, as specified by the root-config’s index.ejs file (there is no root component). With Single-Spa I do not have an App to wrap, as one normally would with React, though my individual components are still React-based.

```auto
  <template id="single-spa-layout">
    <single-spa-router mode="history" base="/">
        <application name="@example/navbar-app"></application>
        <br/>
        <main>
          <route path="home">
            <div class="d-flex justify-content-around">
              <application name="@example/app1"></application>
              <application name="@example/app2"></application>
            </div> 
            <div class="d-flex justify-content-around">
              <application name="@example/lookup"></application>
            </div> 
          </route>  
        </main> 
    </single-spa-router>
  </template>

```

I tried to wrap the Navbar, which displays on every page, but am getting the error:  
**You forgot to wrap your component in Auth0Provider**

```auto
const {
  isLoading,
  isAuthenticated,
  error,
  user,
  loginWithRedirect,
  logout,
} = useAuth0();

return (
  <div>
    <Auth0Provider
      domain={auth_config.domain}
      client_id={auth_config.clientId}
      redirectUri="https://example.com"
    >
      <Navbar bg="dark" variant="dark">
        <Container>
          <Navbar.Brand>Navbar</Navbar.Brand>
            <Nav className="me-auto">
              { isAuthenticated ?
                [ <Nav.Link href="/home">Home</Nav.Link>,
                  <Nav.Link href="/lookup">Redirect</Nav.Link>,
                  <Nav.Link onClick={logout}>Logout</Nav.Link>
                ]
                : <Nav.Link onClick={loginWithRedirect}>Login</Nav.Link>
              }
            </Nav>
        </Container>
      </Navbar>
    </Auth0Provider>
  </div>
);

```

---

<div class="post-metadata">

**Author:** ![natasha-b](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/natasha-b/32/34987_2.png) [@natasha-b](https://community.auth0.com/u/natasha-b)\
**Post date:** [February 7, 2022, 4:46pm UTC](https://community.auth0.com/t/auth0-react-and-single-spa-you-forgot-to-wrap-your-component-in-auth0provider/77731/2 "2022-02-07T16:46:38Z")

</div>

I created a component that contained the navbar and imported it into this rootComponent, wrapping the imported navbar in Auth0Provider.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 22, 2022, 2:22pm UTC](https://community.auth0.com/t/auth0-react-and-single-spa-you-forgot-to-wrap-your-component-in-auth0provider/77731/3 "2022-02-22T14:22:52Z")

</div>

Perfect! Thanks for sharing it with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 22, 2022, 2:22pm UTC](https://community.auth0.com/t/auth0-react-and-single-spa-you-forgot-to-wrap-your-component-in-auth0provider/77731/4 "2022-02-22T14:22:55Z")

</div>


