# Logout from an React App with Custom Social Connection does not work

**URL:** <https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797>\
**Category:** Get Help\
**Tags:** logout\
**Created:** [March 21, 2021, 9:38am UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797 "2021-03-21T09:38:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![allen2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/allen2/32/13075_2.png) [@allen2](https://community.auth0.com/u/allen2)\
**Post date:** [March 21, 2021, 9:38am UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/1 "2021-03-21T09:38:35Z")

</div>

I added a Custom Social Connection(which links to my another tenant application) to my React app. If I login from this Custom Social Connection, after I logout, and click login again, it did not popup username/password fields for me to type credentials. How can i logout from this Custom Social Connection(another tenant)?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 22, 2021, 7:18pm UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/3 "2021-03-22T19:18:50Z")

</div>

Hi @allen2,

Welcome to the Community!

Would you mind sharing your code where you log out? For example:

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

const NavBar = () => {
  const [isOpen, setIsOpen] = useState(false);
  const {
    user,
    isAuthenticated,
    loginWithRedirect,
    logout,
  } = useAuth0();
  const toggle = () => setIsOpen(!isOpen);

  const logoutWithRedirect = () =>
    logout({
      returnTo: window.location.origin,
    });

  return (
    <div className="nav-container">
      <Navbar color="light" light expand="md">
        <Container>
          <Collapse isOpen={isOpen} navbar>
            <Nav className="mr-auto" navbar>
              <NavItem>
                <NavLink
                  tag={RouterNavLink}
                  to="/"
                  exact
                  activeClassName="router-link-exact-active"
                >
                  Home
                </NavLink>
              </NavItem>
              {isAuthenticated && (
                <NavItem>
                  <NavLink
                    tag={RouterNavLink}
                    to="/external-api"
                    exact
                    activeClassName="router-link-exact-active"
                  >
                    External API
                  </NavLink>
                </NavItem>
              )}
            </Nav>
            <Nav className="d-none d-md-block" navbar>
              {!isAuthenticated && (
                <NavItem>
                  <Button
                    id="qsLoginBtn"
                    color="primary"
                    className="btn-margin"
                    onClick={() => loginWithRedirect()}
                  >
                    Log in
                  </Button>
                </NavItem>
              )}
              {isAuthenticated && (
                <UncontrolledDropdown nav inNavbar>
                  <DropdownToggle nav caret id="profileDropDown">
                    <img
                      src={user.picture}
                      alt="Profile"
                      className="nav-user-profile rounded-circle"
                      width="50"
                    />
                  </DropdownToggle>
                  <DropdownMenu>
                    <DropdownItem header>{user.name}</DropdownItem>
                    <DropdownItem
                      tag={RouterNavLink}
                      to="/profile"
                      className="dropdown-profile"
                      activeClassName="router-link-exact-active"
                    >
                      <FontAwesomeIcon icon="user" className="mr-3" /> Profile
                    </DropdownItem>
                    <DropdownItem
                      id="qsLogoutBtn"
                      onClick={() => logoutWithRedirect()}
                    >
                      <FontAwesomeIcon icon="power-off" className="mr-3" /> Log
                      out
                    </DropdownItem>
                  </DropdownMenu>
                </UncontrolledDropdown>
              )}
            </Nav>
            {!isAuthenticated && (
              <Nav className="d-md-none" navbar>
                <NavItem>
                  <Button
                    id="qsLoginBtn"
                    color="primary"
                    block
                    onClick={() => loginWithRedirect()}
                  >
                    Log in
                  </Button>
                </NavItem>
              </Nav>
            )}
            {isAuthenticated && (
              <Nav
                className="d-md-none justify-content-between"
                navbar
                style={{ minHeight: 170 }}
              >
                <NavItem>
                  <FontAwesomeIcon icon="power-off" className="mr-3" />
                  <RouterNavLink
                    to="#"
                    id="qsLogoutBtn"
                    onClick={() => logoutWithRedirect()}
                  >
                    Log out
                  </RouterNavLink>
                </NavItem>
              </Nav>
            )}
          </Collapse>
        </Container>
      </Navbar>
    </div>
  );
};

export default NavBar;

```

Also, does this behavior happen with other social connections (such as Google) or is it only with the custom social connection?

Thanks!

---

<div class="post-metadata">

**Author:** ![allen2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/allen2/32/13075_2.png) [@allen2](https://community.auth0.com/u/allen2)\
**Post date:** [March 23, 2021, 12:44am UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/4 "2021-03-23T00:44:14Z")

</div>

Thanks Stephanie. You are right, that’s the common behaviour with social connections(Google).

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 26, 2021, 11:56am UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/5 "2021-03-26T11:56:55Z")

</div>

That is helpful to know! Have you been able to find the solution to logging out? If not, would you be able to send a snippet of code where you are logging out so that I might be able to replicate this behavior? Thanks!

---

<div class="post-metadata">

**Author:** ![allen2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/allen2/32/13075_2.png) [@allen2](https://community.auth0.com/u/allen2)\
**Post date:** [March 28, 2021, 9:22am UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/6 "2021-03-28T09:22:13Z")

</div>

Thanks for following up. Actually I did not customise any code, just follow with the auth0 react example which is exactly like the code snippet you provided above.  
`
const logoutWithRedirect = () =>
logout({
returnTo: window.location.origin,
});
`  
My business logic is setup via the auth0 dashboard:  
I have TWO tenants: Tenant\_A and Tenant\_B. Tenant\_A has an App\_A with UserPool\_A, Tenant\_B has an App\_B with UserPool\_B.  
The requirement is, when user lands on App\_A login page, he/she should be able to authenticated either via UserPool\_A or UserPool\_B to access App\_A.  
So I created a Custom Social Connection on Tenant\_A to connect with App\_B. It works well. The only issue is, when user login via this CustomSocialConnection and logout and try CustomSocialConnection again, it automatically authorise the user without popup login form. I also tried Google Social Connection, same behaviour. However, if different users use the same computer with CustomSocialConnection, it will be a problem.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 29, 2021, 6:23pm UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/7 "2021-03-29T18:23:50Z")

</div>

I haven’t been able to recreate this behavior, but have you tried passing `prompt=login` to the `/authorize` endpoint so that the user will always see the login form:

`loginWithRedirect({ prompt: 'login' });`

---

<div class="post-metadata">

**Author:** ![basit1991](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/basit1991/32/25743_2.png) [@basit1991](https://community.auth0.com/u/basit1991)\
**Post date:** [March 29, 2021, 7:06pm UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/8 "2021-03-29T19:06:30Z")

</div>

> [@stephanie.chamblee](#):
>
> ```auto
> const logoutWithRedirect = () =>
> logout({
> returnTo: window.location.origin,
> });
> 
> ```

Thanks @stephanie.chamblee, this worked for my use case. Wasn’t clear in auth0 docs.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 29, 2021, 7:07pm UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/9 "2021-03-29T19:07:38Z")

</div>

I’m glad that it is working!

---

<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:** [April 13, 2021, 7:08pm UTC](https://community.auth0.com/t/logout-from-an-react-app-with-custom-social-connection-does-not-work/59797/10 "2021-04-13T19:08:14Z")

</div>

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