better-auth-authentication

better-auth-authentication

Better Auth authentication flows for TypeScript apps. Use when enabling email/password auth, configuring social providers, or implementing sign-up, sign-in, and verification flows.

9Star
2Fork
更新于 1/29/2026
SKILL.md
readonly只读
name
better-auth-authentication
description

Better Auth authentication flows for TypeScript apps. Use when enabling email/password auth, configuring social providers, or implementing sign-up, sign-in, and verification flows.

Better Auth Authentication

Goals

  • Enable email/password authentication and social providers.
  • Implement sign-up, sign-in, sign-out, and verification flows.
  • Handle redirects and errors consistently.

Quick start

  1. Enable emailAndPassword and configure socialProviders.
  2. Create a client with createAuthClient.
  3. Use signUp.email, signIn.email, signIn.social, and signOut on the client.
import { betterAuth } from "better-auth";

export const auth = betterAuth({
  emailAndPassword: { enabled: true },
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID as string,
      clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
    },
  },
});
import { createAuthClient } from "better-auth/client";

const authClient = createAuthClient();

await authClient.signUp.email({
  email,
  password,
  name,
});

await authClient.signIn.email({
  email,
  password,
  callbackURL: "/dashboard",
});

await authClient.signIn.social({
  provider: "github",
  callbackURL: "/dashboard",
});

await authClient.signOut();

Email verification

  • Provide emailVerification.sendVerificationEmail to send the verification link.
  • Use emailAndPassword.requireEmailVerification to enforce verification before sign-in.

Social providers

  • Configure providers in socialProviders with provider-specific credentials.
  • Use signIn.social to start OAuth flows.
  • Pass callbackURL, errorCallbackURL, and newUserCallbackURL for redirects.

Guardrails

  • Call client methods from the client only.
  • Keep secrets in server-only env variables.
  • Use rememberMe to control persistent sessions on email/password sign-in.

References

  • toolchains/platforms/auth/better-auth/better-auth-authentication/references/email-password.md
  • toolchains/platforms/auth/better-auth/better-auth-authentication/references/providers.md

You Might Also Like

Related Skills

verify

verify

243K

Use when you want to validate changes before committing, or when you need to check all React contribution requirements.

facebook avatarfacebook
获取
test

test

243K

Use when you need to run tests for React core. Supports source, www, stable, and experimental channels.

facebook avatarfacebook
获取

Use when feature flag tests fail, flags need updating, understanding @gate pragmas, debugging channel-specific test failures, or adding new flags to React.

facebook avatarfacebook
获取

Use when adding new error messages to React, or seeing "unknown error code" warnings.

facebook avatarfacebook
获取
flow

flow

243K

Use when you need to run Flow type checking, or when seeing Flow type errors in React code.

facebook avatarfacebook
获取
flags

flags

243K

Use when you need to check feature flag states, compare channels, or debug why a feature behaves differently across release channels.

facebook avatarfacebook
获取