# How to logout out of a React web app without using the React SDK?

**URL:** <https://community.auth0.com/t/how-to-logout-out-of-a-react-web-app-without-using-the-react-sdk/103697>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [March 29, 2023, 11:25pm UTC](https://community.auth0.com/t/how-to-logout-out-of-a-react-web-app-without-using-the-react-sdk/103697 "2023-03-29T23:25:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zprangon](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@zprangon](https://community.auth0.com/u/zprangon)\
**Post date:** [March 29, 2023, 11:25pm UTC](https://community.auth0.com/t/how-to-logout-out-of-a-react-web-app-without-using-the-react-sdk/103697/1 "2023-03-29T23:25:09Z")

</div>

Hi, I am trying to setup a authentication flow for my web app created using react. I have been using the `@auth0/auth0-react` sdk for development. The problem with this is I am trying to provide the login component from a shared library which is wrapped with a provider like this:

```auto
    <Auth0Provider
      domain={auth0Config.domain}
      clientId={auth0Config.clientId}
      authorizationParams={{
        redirect_uri: auth0Config.redirectURI,
        scope: '...',
      }}
    >{HERE IS THE LOGIN COMPONENT} </Auth0Provider>

```

Now the problem is when I try to logout from the application like this:

```auto
import React from "react";
import { useAuth0 } from "@auth0/auth0-react";

const LogoutButton = () => {
  const { logout } = useAuth0();

  return (
    <button onClick={() => logout({ logoutParams: { returnTo: window.location.origin } })}>
      Log Out
    </button>
  );
};

export default LogoutButton;

```

I get an error that says:

```auto
You forgot to wrap your component in <Auth0Provider>.

```

I understand this error is because the Logout button is not under the React Context/Auth0Provider. However, I would like to know if there’s a way I can accomplish logout without using the logout method from the `useAuth0()` hook. Thanks!

---

<div class="post-metadata">

**Author:** ![alex.brett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex.brett/32/60157_2.png) [@alex.brett](https://community.auth0.com/u/alex.brett)\
**Post date:** [November 18, 2024, 11:34pm UTC](https://community.auth0.com/t/how-to-logout-out-of-a-react-web-app-without-using-the-react-sdk/103697/2 "2024-11-18T23:34:32Z")

</div>

Hello @zprangon! Thanks for reaching out.

I managed to find a few other posts regarding this issue:

> <https://stackoverflow.com/questions/70760724/how-to-logout-with-auth0-sdk-you-forgot-to-wrap-your-component-in-auth0provid>

> [@Auth0, React and Single-Spa - \[You forgot to wrap your component in \<Auth0Provider\>\]](https://community.auth0.com/t/auth0-react-and-single-spa-you-forgot-to-wrap-your-component-in-auth0provider/77731):
>
> 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: \<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 …

> [@"You forgot to wrap your component in \<Auth0Provider\>" only in built application](https://community.auth0.com/t/you-forgot-to-wrap-your-component-in-auth0provider-only-in-built-application/120322/3):
>
> Hi @mschersten, Welcome to the Auth0 Community! Here’s a couple of threads that provide additional context on the error you’re seeing. If you don’t find an answer here, can you please share some code snippets of your implementation. Don’t include any sensitive data.

Please let me know if these help!

Best,  
Alex

---

<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:** [December 2, 2024, 11:35pm UTC](https://community.auth0.com/t/how-to-logout-out-of-a-react-web-app-without-using-the-react-sdk/103697/3 "2024-12-02T23:35:01Z")

</div>

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