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

Better Auth · Function

signOut

Signs out the current user through Better Auth’s client API. Optional fetch options can run logic such as redirecting to the login page after successful sign-out.

How it works

Call the client’s signOut method to end the current user session. You may provide fetchOptions to run an onSuccess callback, such as navigating to a login route after logout completes.

Syntax

await authClient.signOut(options)

Parameters

NameTypeDescription
optionsobjectOptional request configuration, including a fetchOptions object with an onSuccess callback.

Returns

A promise for the asynchronous sign-out request.

Key points

  • Use the client-provided signOut function to terminate the user’s session.
  • The minimal invocation is an awaited call with no arguments.
  • Optional fetch options support handling successful logout, including navigation.
  • A successful logout can send the user to the login page.

Common mistakes

  • A redirect callback is supplied through fetchOptions rather than as a top-level redirect option.

Example: Sign out and redirect

import { authClient } from "@/lib/auth-client";

await authClient.signOut({
  fetchOptions: {
    onSuccess: () => {
      router.push("/login");
    },
  },
});

Signs out through the client and navigates to the login page after a successful response.

When to use it

Basic logout

A user clicks a logout control in a web application.

Post-logout navigation

The application should return users to authentication after logout succeeds.

Success handling

A client needs to run cleanup or UI updates after the sign-out request completes.

Interview questions

QHow do you sign a user out with Better Auth?

Use the client method authClient.signOut(). It signs out the user, and the request can be followed by a success callback supplied under fetchOptions.

Follow-up: How would you redirect after logout? Pass fetchOptions.onSuccess and navigate to the login page from that callback.

QHow can sign-out trigger a redirect?

Call authClient.signOut({ fetchOptions: { onSuccess: ... } }). The callback runs after a successful sign-out and can perform application navigation.

Follow-up: What is the simplest form when no navigation is needed? Use await authClient.signOut() without options.

QWhat is the basic usage pattern for sign-out?

The documented client call is asynchronous, so await authClient.signOut() to complete the operation before continuing. The basic usage page presents this call as the client-side sign-out mechanism.

Follow-up: What should be added for a post-logout route? Configure an onSuccess callback inside fetchOptions.

  • authClient
  • fetchOptions
  • onSuccess

Source: Basic Usage | Better Auth. Checked 2026-10-15.