Logout

The page the Salla SDK sends the browser to after sign-out; it clears the token cookie and goes home.

Framework: TanStack Start

This page is written for TanStack Start, the default and currently supported framework. See what depends on the framework.

The customer never sees this page for more than a moment. When they sign out, the Salla SDK (Salla.auth.logout()) sends the browser to /logout, which clears the theme's token cookie and goes to the store home. Customise it only to show a short "signing out" message.

URL

URLGoes to
/logout?from=...the same path without /logout, which is the home page
/ar/logout?from=.../ar

The only param is the optional locale. The from query is ignored.

Route file

app/routes/logout.tsx
// @auto-generated
import { createFileRoute } from '@tanstack/react-router';
import { LogoutRedirect } from '@salla.sa/twilight-theme-engine/routes/seo-redirects';

export const Route = createFileRoute('/{-$locale}/logout')({
  component: LogoutRedirect,
});

To take the file over, delete the // @auto-generated line. See Fork a built-in route.

A customised version

Show a message while the redirect runs. Keep LogoutRedirect mounted: it is what clears the cookie and navigates.

app/routes/logout.tsx
import { createFileRoute } from '@tanstack/react-router';
import { LogoutRedirect } from '@salla.sa/twilight-theme-engine/routes/seo-redirects';

export const Route = createFileRoute('/{-$locale}/logout')({
  component: function LogoutRoute() {
    return (
      <>
        <p className="py-16 text-center">Signing you out...</p>
        <LogoutRedirect />
      </>
    );
  },
});

What it loads

Nothing. There is no loader and no head. LogoutRedirect renders nothing and does its work in the browser. It is a component, not a loader redirect, because a loader runs on the server, where the cookie cannot be cleared and the customer would stay signed in on the next request.

Edge cases

  • The cookie. Salla.cookie.clearAll() leaves the theme's token cookie behind, so this page deletes it. A custom sign-out that skips this looks signed out in the SDK but still sends a token to the API.
  • Visited while signed out. It does the same thing and goes home.
  • Navigation. It replaces the history entry with a full page load, and keeps the store path and language prefix in front of /logout.
  • JavaScript disabled. The page stays blank, because nothing runs on the server.

See also

On this page