# Auth0-spa-js, passing returnTo to logout not working

**URL:** <https://community.auth0.com/t/auth0-spa-js-passing-returnto-to-logout-not-working/96855>\
**Category:** Get Help\
**Tags:** react\
**Created:** [December 20, 2022, 9:46pm UTC](https://community.auth0.com/t/auth0-spa-js-passing-returnto-to-logout-not-working/96855 "2022-12-20T21:46:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joshy/32/34658_2.png) [@joshy](https://community.auth0.com/u/joshy)\
**Post date:** [December 20, 2022, 9:46pm UTC](https://community.auth0.com/t/auth0-spa-js-passing-returnto-to-logout-not-working/96855/1 "2022-12-20T21:46:31Z")

</div>

Hey all,

I am passing the returnTo parameter to my logout function. However, upon log out the redirect to the logout/v2 endpoint has my client id, but doesn’t specify the return to parameter. It’s not getting set on the logout request… Any insights on why or how this could happen?

```auto
const logout = useCallback(async () => {
    console.log("auth0 logout called.");
    const logoutOptions = {returnTo: "https://app.test.com"};
    auth0Client?.logout(logoutOptions);
    dispatch({
      type: 'LOGOUT',
    });
  }, []);

```

---

<div class="post-metadata">

**Author:** ![joshy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/joshy/32/34658_2.png) [@joshy](https://community.auth0.com/u/joshy)\
**Post date:** [December 20, 2022, 10:03pm UTC](https://community.auth0.com/t/auth0-spa-js-passing-returnto-to-logout-not-working/96855/2 "2022-12-20T22:03:17Z")

</div>

I solved this, apparently with auth0-spa-js you need to add a top level logoutParams:

```auto
auth0Client?.logout({logoutParams:{returnTo: window.location.origin}});

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 20, 2022, 10:32pm UTC](https://community.auth0.com/t/auth0-spa-js-passing-returnto-to-logout-not-working/96855/3 "2022-12-20T22:32:11Z")

</div>

Hey @joshy welcome to the community and good to know you were able to resolve this - Thanks a bunch for following up with the community! 😄

---

<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:** [January 3, 2023, 10:32pm UTC](https://community.auth0.com/t/auth0-spa-js-passing-returnto-to-logout-not-working/96855/4 "2023-01-03T22:32:31Z")

</div>

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