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

Better Auth · Const

signIn

Better Auth’s signIn client API supports email/password authentication through signIn.email and social authentication through signIn.social. Email sign-in accepts credentials plus optional session persistence and redirect settings.

How it works

signIn is the client authentication entry point. Use its email method with credentials and optional session behavior or redirect settings; for social authentication, use its social method with a configured provider.

Syntax

await authClient.signIn.email({ email, password, rememberMe?, callbackURL? })

Parameters

NameTypeDescription
emailstring, requiredThe account email address.
passwordstring, requiredThe account password; 8–128 characters by default.
rememberMeboolean, optionalWhether the session should persist after the browser closes; defaults to true.
callbackURLstring, optionalURL to redirect to after successful sign-in.

Returns

The client call resolves to an object containing data and error; successful authentication returns sign-in data, while failures are represented by error.

Key points

  • For password-based authentication, call the client’s signIn.email method.
  • The email field identifies the account that should authenticate.
  • The password field supplies the credential checked during sign-in.
  • Use callbackURL when the application should redirect the user after authentication.
  • Social authentication uses the separate signIn.social method.
  • A social sign-in request selects its identity provider with a provider ID.

Common mistakes

  • Passwords must normally be between 8 and 128 characters unless the authentication configuration changes those limits.
  • Setting rememberMe to false makes the session end when the browser closes.
  • Email/password sign-in requires enabling the email-and-password authenticator in the server configuration.

Example: Sign in with email and password

import { createAuthClient } from "better-auth/client";

const authClient = createAuthClient();

const { data, error } = await authClient.signIn.email({
  email: "john.doe@example.com",
  password: "password1234",
  rememberMe: true,
});

if (error) console.error(error);
else console.log(data);

Creates a Better Auth client and signs in with an email and password, then handles either the returned error or successful data.

When to use it

Password-based login

A user enters an email address and password in a login form.

Social login

A user authenticates through Google, GitHub, Apple, or another configured provider.

Session persistence choice

An application needs to control whether a session survives browser closure.

Post-login redirect

A login flow must send the user to a specific page after success.

Interview questions

QHow does a client sign in with email and password?

Use authClient.signIn.email with an object containing the user’s email and password. The result exposes data and error, so the caller can handle authentication success or failure explicitly.

Follow-up: How would you support OAuth instead? Call authClient.signIn.social with the configured provider ID, such as google or github.

QWhat do rememberMe and callbackURL control?

The request accepts rememberMe; when it is false, the user is signed out after the browser closes. It also accepts an optional callbackURL for redirecting after successful sign-in.

Follow-up: What must be configured before this call can work? Enable emailAndPassword in the auth configuration and ensure the client is created against the Better Auth instance.

QHow does signIn differ for social providers?

Better Auth supports client-side social sign-in through authClient.signIn.social. The call receives a provider identifier, and that provider must be configured in the auth instance’s socialProviders option.

Follow-up: How can a server initiate social sign-in? Use the corresponding auth.api.signInSocial method with the provider in its request body.

  • signUp.email
  • signIn.social
  • auth.api.signInEmail
  • auth.api.signInSocial
  • emailAndPassword.enabled
  • socialProviders

Source: Email & Password | Better Auth. Checked 2026-10-15.