Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Kinde · Module

logout

The TypeScript SDK’s logout method creates a Kinde logout URL from a session manager. Redirect the user to that URL to complete sign-out and return them to the configured post-logout destination.

How it works

The TypeScript SDK logout method receives the session manager and returns a logout URL. Redirect the user to that URL so Kinde can end the session and send the user back to a configured allowed logout redirect URL.

Syntax

kindeClient.logout(sessionManager)

Parameters

NameTypeDescription
sessionManagerSessionManagerSession manager used by the SDK to access the current authenticated session.

Returns

A logout URL that should be used as the destination of an HTTP redirect.

Key points

  • The TypeScript SDK provides a dedicated logout method for ending a Kinde session.
  • Invoke the method asynchronously with the application’s session manager.
  • Redirect the response to the generated logout URL.
  • Configure the post-logout destination as the location users should return to after sign-out.

Common mistakes

  • The post-logout destination must be registered in the application’s Allowed logout redirect URLs configuration.

Example: Redirect to Kinde logout

import { KindeClient } from "@kinde/typescript-sdk";

app.get("/logout", async (req, res) => {
  const logoutUrl = await kindeClient.logout(sessionManager);
  res.redirect(logoutUrl.toString());
});

Create a logout route, generate Kinde's logout URL with the session manager, and redirect the browser to it.

When to use it

Handle a sign-out route

Server-rendered or Express-style application

Connect a sign-out link to the route

Navigation-based authentication UI

Send users to a configured post-logout page

Applications with a fixed return location

Interview questions

QHow do you implement logout with the TypeScript SDK?

Call kindeClient.logout(sessionManager) from a server route and await the returned URL. Redirect the browser to that URL rather than treating logout as only local session cleanup.

Follow-up: What configuration is needed for the final destination? Register the destination as an Allowed logout redirect URL and configure the SDK’s logout redirect URL accordingly.

QWhat are the parameter and return value of logout?

The method accepts one argument: a SessionManager. Its result is a URL, which the application should convert to a string and pass to the response redirect.

Follow-up: Why redirect instead of returning the URL as JSON? The browser must navigate to Kinde’s logout endpoint to complete the hosted sign-out flow.

QHow should a user-facing sign-out link invoke logout?

Expose an application route such as /logout, invoke the SDK method there, and redirect to the generated URL. A sign-out link can target that route so the flow runs on the server.

Follow-up: What should be checked if redirecting fails? Verify that the configured post-logout URL exactly matches an allowed logout redirect URL.

  • SessionManager
  • logoutRedirectURL
  • Allowed logout redirect URLs
  • /logout

Source: TypeScript. Checked 2026-10-15.