# Achieving Local-Only Logout with SSO Across Two Apps (React & NextJS)

**URL:** <https://community.auth0.com/t/achieving-local-only-logout-with-sso-across-two-apps-react-nextjs/181512>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [February 5, 2025, 4:56pm UTC](https://community.auth0.com/t/achieving-local-only-logout-with-sso-across-two-apps-react-nextjs/181512 "2025-02-05T16:56:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktvrdi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ktvrdi/32/72659_2.png) [@ktvrdi](https://community.auth0.com/u/ktvrdi)\
**Post date:** [February 5, 2025, 4:56pm UTC](https://community.auth0.com/t/achieving-local-only-logout-with-sso-across-two-apps-react-nextjs/181512/1 "2025-02-05T16:56:32Z")

</div>

Hello Auth0 Community,

I have two separate applications:

1. **App A** (React)

2. **App B** (Next.js v14.2.17 using @auth0/nextjs-auth0 v3.6.0)

I want to achieve **SSO** such that if a user logs in through App A, they can seamlessly access App B (and vice versa) without re-entering credentials. However, once logged in, these two apps should maintain **independent** logout behavior:

• If the user logs out of App A, they should **remain** logged in on App B until their session naturally expires or they explicitly log out of App B.

• Likewise, logging out of App B should not affect the session on App A.

Essentially, **shared login** but **local-only logout** in each app.

Has anyone successfully configured this scenario with a similar setup?

Any guidance or examples on how to configure @auth0/nextjs-auth0 and an Auth0 tenant to get local-only logouts while preserving SSO would be greatly appreciated!

Thanks!

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [February 5, 2025, 6:42pm UTC](https://community.auth0.com/t/achieving-local-only-logout-with-sso-across-two-apps-react-nextjs/181512/3 "2025-02-05T18:42:34Z")

</div>

Hi @ktvrdi,

Welcome to the Auth0 Community and thank you for posting your inquiry.

Even though you have a SSO implementation the logout sessions within your applications are already **independent** from each other, meaning that if a user logs out of the Application1 that user will remain logged in on the Application2 and vice-versa. This is the natural behavior for the SSO protocol unless you have manually integrated either [federated logout](https://auth0.com/docs/authenticate/login/logout/log-users-out-of-idps) or implemented [Single Logout](https://auth0.com/docs/authenticate/login/logout/log-users-out-of-saml-idps).

I hope this helped.  
Best regards,  
Remus

---

<div class="post-metadata">

**Author:** ![ktvrdi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ktvrdi/32/72659_2.png) [@ktvrdi](https://community.auth0.com/u/ktvrdi)\
**Post date:** [February 6, 2025, 9:31am UTC](https://community.auth0.com/t/achieving-local-only-logout-with-sso-across-two-apps-react-nextjs/181512/4 "2025-02-06T09:31:37Z")

</div>

Am I doing something wrong here? Since when I log out user from NextJS App B, I need to login again on React App A, which I don’t want to be that case.

We are simply on client side in NextJS we click on `<a href="/api/auth/logout">Log Out</a>`

Sharing code:

```auto
api/auth/callback/routeModule.ts:
export function GET(req: NextRequest, res: AppRouteHandlerFnContext) {
  return handleCallback(req, res);
}

api/auth/login/route.ts:
export function GET(req: NextRequest, res: AppRouteHandlerFnContext) {
  return handleLogin(req, res, {
    returnTo: '/',
  });
}

api/auth/logout/route.ts:
export function GET(req: NextRequest, res: AppRouteHandlerFnContext) {
  return handleLogout(req, res, {
    returnTo: '/',
  });
}

```

Thank you.

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [February 13, 2025, 9:44pm UTC](https://community.auth0.com/t/achieving-local-only-logout-with-sso-across-two-apps-react-nextjs/181512/5 "2025-02-13T21:44:21Z")

</div>

Hi @ktvrdi and sorry for replying late.

After further checking on this matter, when hitting the logout endpoint using the Next.js SDK, this will log the users out globally, meaning that all sessions will get invalidated, including the auth0 session cookie, as detailed in our [documentation](https://auth0.com/docs/manage-users/sessions/session-layers).

One way to go in this use case would be to make sure that the application logs the user out only locally, maintaining the Auth0 session intact for the SSO interaction. You can try passing the `localOnly: true` to the “HandleLogout” function. You can also try not calling the “HandleLogout” at all, but instead create a logout function that deletes the app session when logging out.

I might also recommend checking into implementing [Silent Authentication](https://auth0.com/docs/manage-users/sessions) in case one app already has an active session, and configure the SSO Session Timeout to a lower frame to minimize security risks.

Please let me know if that does the trick.  
Thanks,  
Remus
