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

Kinde · Module

login

Kinde's TypeScript SDK login method creates a redirect URL for sign-in. Call it from a login route and redirect the browser to the returned URL.

How it works

The TypeScript SDK's login method creates the authorization redirect URL for a user sign-in. A server route calls it with the session manager, then redirects the browser to Kinde so authentication can occur.

Syntax

kindeClient.login(sessionManager)

Parameters

NameTypeDescription
sessionManagerSessionManagerSession state manager used by the authentication client.

Returns

A redirect URL that sends the user to Kinde for sign-in.

Key points

  • login starts sign-in by producing a URL that points the browser at Kinde.
  • The SDK call is asynchronous, so await its result before redirecting.
  • Convert the returned URL to text and use it as the HTTP redirect target.

Common mistakes

  • Calling login does not authenticate the user locally; the application must redirect the browser to Kinde.
  • Expose a route such as /login and connect it to the SDK method.

Example: Redirect to Kinde sign-in

import express from "express";
import { KindeClient } from "@kinde/js-node";

const app = express();
const kindeClient = new KindeClient({
  clientId: process.env.KINDE_CLIENT_ID!,
  clientSecret: process.env.KINDE_CLIENT_SECRET!,
  authDomain: process.env.KINDE_AUTH_DOMAIN!,
  redirectUri: "http://localhost:3000/callback",
});

app.get("/login", async (_req, res) => {
  const loginUrl = await kindeClient.login(sessionManager);
  res.redirect(loginUrl.toString());
});

The route obtains Kinde's sign-in redirect URL and sends the browser to it.

When to use it

Add a login route

A server-rendered application needs a sign-in endpoint.

Start hosted authentication

An application delegates credential entry and authentication to Kinde.

Initiate a session-backed flow

A session-aware backend begins an OAuth sign-in flow.

Interview questions

QWhat does the TypeScript SDK login method do?

The method constructs a redirect URL that sends the user to Kinde to sign in. In a server application, the route should call it with the session manager and return a redirect response.

Follow-up: Why pass a session manager? It supplies the session context required by the SDK while constructing the authentication flow.

QHow would you expose login in an Express application?

A typical implementation maps /login to an asynchronous handler, calls kindeClient.login(sessionManager), converts the resulting URL to a string, and redirects the response there.

Follow-up: What should happen after authentication? Kinde should return the browser to a configured callback URL so the application can complete the session flow.

QWhere does the actual sign-in occur?

Login is part of the redirect-based authentication flow rather than a local password-checking function. The user is sent to Kinde, where sign-in takes place.

Follow-up: How could registration be exposed similarly? Add a /register route and connect it to the SDK's registration method.

  • register
  • SessionManager
  • KindeClient

Source: TypeScript. Checked 2026-10-15.