
Better Auth Authentication
- 271 installs
- 63 repo stars
- Updated July 18, 2026
- bobmatnyc/claude-mpm-skills
Integrate Better Auth for sessions, OAuth providers, email login, and route protection in TypeScript web apps with secure cookie defaults.
About
Covers Better Auth setup for modern web apps: provider configuration, session lifecycle, protected routes, social login, database adapters, and secure defaults for SaaS authentication flows in TypeScript stacks.
- OAuth providers
- session cookies
- email password login
- route middleware guards
- database adapters
Better Auth Authentication by the numbers
- 271 all-time installs (skills.sh)
- Ranked #653 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 1, 2026 (Skillselion catalog sync)
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill better-auth-authenticationAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 271 |
|---|---|
| repo stars | ★ 63 |
| Last updated | July 18, 2026 |
| Repository | bobmatnyc/claude-mpm-skills ↗ |
What it does
Integrate Better Auth for sessions, OAuth providers, email login, and route protection in TypeScript web apps with secure cookie defaults.
Files
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.sendVerificationEmailto send the verification link. - Use
emailAndPassword.requireEmailVerificationto enforce verification before sign-in.
Social providers
- Configure providers in
socialProviderswith provider-specific credentials. - Use
signIn.socialto start OAuth flows. - Pass
callbackURL,errorCallbackURL, andnewUserCallbackURLfor redirects.
Guardrails
- Call client methods from the client only.
- Keep secrets in server-only env variables.
- Use
rememberMeto control persistent sessions on email/password sign-in.
References
toolchains/platforms/auth/better-auth/better-auth-authentication/references/email-password.mdtoolchains/platforms/auth/better-auth/better-auth-authentication/references/providers.md
{
"name": "better-auth-authentication",
"version": "1.0.0",
"category": "toolchain",
"toolchain": null,
"tags": [
"better-auth",
"auth",
"email-password",
"social",
"oauth",
"providers",
"typescript"
],
"entry_point_tokens": 200,
"full_tokens": 1151,
"related_skills": [
"better-auth-core",
"better-auth-integrations",
"better-auth-plugins"
],
"author": "Claude MPM",
"license": "MIT",
"platform": "auth"
}
Email and password flows
Enable email and password
import { betterAuth } from "better-auth";
export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
});Sign up
await authClient.signUp.email({
name,
email,
password,
image,
callbackURL: "/dashboard",
});Disable automatic sign-in after sign-up:
export const auth = betterAuth({
emailAndPassword: {
enabled: true,
autoSignIn: false,
},
});Sign in
await authClient.signIn.email({
email,
password,
rememberMe: true,
callbackURL: "/dashboard",
});Sign out
await authClient.signOut();Redirect on sign-out:
await authClient.signOut({
fetchOptions: {
onSuccess: () => {
router.push("/login");
},
},
});Email verification
Provide a server-side function that sends the verification email:
import { betterAuth } from "better-auth";
import { sendEmail } from "./email";
export const auth = betterAuth({
emailVerification: {
sendVerificationEmail: async ({ user, url, token }, request) => {
void sendEmail({
to: user.email,
subject: "Verify your email address",
text: `Click the link to verify your email: ${url}`,
});
},
},
});Require verification on sign-in:
export const auth = betterAuth({
emailAndPassword: {
requireEmailVerification: true,
},
});Handle verification errors on sign-in:
await authClient.signIn.email(
{ email, password },
{
onError: (ctx) => {
if (ctx.error.status === 403) {
alert("Please verify your email address");
}
},
}
);Social providers
Configure providers
Set providers in socialProviders and pass provider credentials.
import { betterAuth } from "better-auth";
export const auth = betterAuth({
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
},
},
});Sign in with a provider
await authClient.signIn.social({
provider: "github",
callbackURL: "/dashboard",
errorCallbackURL: "/error",
newUserCallbackURL: "/welcome",
disableRedirect: false,
});Provider docs
Use provider-specific docs to configure redirect URLs and scopes.
Common providers:
- GitHub: https://www.better-auth.com/docs/authentication/github
- Google: https://www.better-auth.com/docs/authentication/google
- Apple: https://www.better-auth.com/docs/authentication/apple
- Discord: https://www.better-auth.com/docs/authentication/discord
- GitLab: https://www.better-auth.com/docs/authentication/gitlab
- Microsoft: https://www.better-auth.com/docs/authentication/microsoft
- Slack: https://www.better-auth.com/docs/authentication/slack
More providers:
- Other social providers list: https://www.better-auth.com/docs/authentication/other-social-providers