betterauth
BetterAuth integration patterns — setup, session management, OAuth providers, middleware protection, and security best practices for authentication in…
Skill by Satcomx00-x00
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/satcomx00-x00-betterauth
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/betterauth
What's inside
- Skill name
betterauth- Description
- BetterAuth integration patterns — setup, session management, OAuth providers, middleware protection, and security best practices for authentication in TypeScript/Next.js applications.
- License
- MIT
- Metadata
- author: Satcomx00-x00 · version: 1.0.0
- Instructions
- 248 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# betterauth
BetterAuth integration patterns — setup, session management, OAuth providers, middleware protection, and security best practices for authentication in TypeScript/Next.js applications.
## Instructions
Apply these practices when integrating BetterAuth into your application:
### Setup & Configuration
Create a single authoritative auth instance and export typed helpers from it:
```ts
// lib/auth.ts
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { db } from './db';
export const auth = betterAuth({
database: prismaAdapter(db, { provider: 'postgresql' }),
emailAndPassword: { enabled: true },
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
},
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
},
},
session: {
expiresIn: 60 * 60 * 24 * 7, // 7 days
updateAge: 60 * 60 * 24, // refresh session if older than 1 day
cookieCache: { enabled: true, maxAge: 60 * 5 }, // 5-minute client cache
},
trustedOrigins: [process.env.NEXT_PUBLIC_APP_URL!],
});
// Export typed client helpers
export type Session = typeof auth.$Infer.Session;
```
### API Route Handler
Mount the BetterAuth catch-all handler at `app/api/auth/[...all]/route.ts`:
```ts
// app/api/auth/[...all]/route.ts
import { auth } from '@/lib/auth';
import { toNextJsHandler } from 'better-auth/next-js';
export const { GET, POST } = toNextJsHandler(auth);
```
### Client-Side Auth Client
Create a single client instance to use across Client Components:
```ts
// lib/auth-client.ts
import { createAuthClient } from 'better-auth/react';
export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_APP_URL!,
});
export const { signIn, signOut, signUp, useSession } = authClient;
```
### Session Access
**Server Component:**
```ts
import { auth } from '@/lib/auth';
import { headers } from 'next/headers';
export async function getServerSession() {
const session = await auth.api.getSession({ headers: await headers() });
return session;
}
```
**Client Component:**
```tsx
'use client';
import { useSession } from '@/lib/auth-client';
export function UserAvatar() {
const { data: session, isPending } = useSession();
if (isPending) return <Skeleton />;
if (!session) return null;
return <img src={session.user.image ?? ''} alt={session.user.name} />;
}
```
### Route Protection
Protect routes at the middleware layer to avoid unnecessary page renders for unauthenticated users:
```ts
// middleware.ts
import { NextRequest, NextResponse } from 'next/server';
import { auth } from '@/lib/auth';
const PROTECTED = ['/dashboard', '/settings', '/api/protected'];
export async function middleware(req: NextRequest) {
const isProtected = PROTECTED.some(path => req.nextUrl.pathname.startsWith(path));
if (!isProtected) return NextResponse.next();
const session = await auth.api.getSession({ headers: req.headers });
if (!session) {
const loginUrl = new URL('/login', req.url);
loginUrl.searchParams.set('callbackUrl', req.nextUrl.pathname);
return NextResponse.redirect(loginUrl);
}
return NextResponse.next();From Satcomx00-x00/skills-db, MIT.
More from Satcomx00-x00/skills-db
- 0.470score
frontend-smell
Satcomx00-x00
Deep-audit TypeScript, React, Next.js (App Router) and frontend-design code for smells — patterns that ship but corrode performance, a11y, type safety, bundle…
SkillCFreshness: CClaude Code +9 - 0.409score
cowork-plugin-customizer
Satcomx00-x00
Customize a Claude Code plugin for a specific organization's tools and workflows.
SkillDFreshness: DClaude Code +9 - 0.406score
code-review
Satcomx00-x00
Code review standards and checklist — how to give constructive feedback, what to look for, and how to approve or request changes effectively.
SkillDFreshness: DClaude Code +9 - 0.406score
devops
Satcomx00-x00
CI/CD pipeline design and DevOps practices — GitHub Actions workflows, deployment strategies, infrastructure-as-code patterns, and observability basics.
SkillDFreshness: DClaude Code +9 - 0.406score
docker
Satcomx00-x00
Docker containerization best practices — writing lean Dockerfiles, multi-stage builds, image security, and docker-compose patterns for local development.
SkillDFreshness: DClaude Code +9 - 0.406score
backend
Satcomx00-x00
Backend and API design patterns — RESTful and GraphQL API conventions, error handling, pagination, authentication patterns, and database best practices.
SkillDFreshness: DClaude Code +9 - 0.406score
git
Satcomx00-x00
Git workflow best practices — conventional commits, branching strategy, rebase/merge patterns, and commit hygiene for clean project history.
SkillDFreshness: DClaude Code +9 - 0.406score
frontend
Satcomx00-x00
Frontend development patterns — component design, accessibility, performance optimisation, and state management best practices for modern web UIs.
SkillDFreshness: DClaude Code +9 - 0.406score
code-quality
Satcomx00-x00
Code quality mastery — programming principles (SOLID, DRY, KISS, YAGNI…), refactoring techniques, and design patterns to write clean, maintainable, extensible…
SkillDFreshness: DClaude Code +9 - 0.406score
nextjs
Satcomx00-x00
Next.js 15 / React 19 state-of-the-art — App Router, async request APIs, use cache directive, Turbopack, Server Functions, Partial Prerendering, and…
SkillDFreshness: DClaude Code +9 - 0.406score
saas
Satcomx00-x00
SaaS state-of-the-art — multi-tenancy, usage-based billing, PLG, AI feature integration, modern observability, compliance, and security for production…
SkillDFreshness: DClaude Code +9 - 0.405score
doc-operationnelle
Satcomx00-x00
Skill based on "Documentation opérationnelle : structurer pour retrouver" (blog.stephane-robert.info).
SkillDFreshness: DClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Apr 13, 2026 (6 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.0.0
- License
- MIT
- Repository
- github.com/Satcomx00-x00/skills-db
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Satcomx00-x00
- 0.470score
frontend-smell
Satcomx00-x00
Deep-audit TypeScript, React, Next.js (App Router) and frontend-design code for smells — patterns that ship but corrode performance, a11y, type safety, bundle…
SkillCFreshness: CClaude Code +9 - 0.409score
cowork-plugin-customizer
Satcomx00-x00
Customize a Claude Code plugin for a specific organization's tools and workflows.
SkillDFreshness: DClaude Code +9 - 0.406score
backend
Satcomx00-x00
Backend and API design patterns — RESTful and GraphQL API conventions, error handling, pagination, authentication patterns, and database best practices.
SkillDFreshness: DClaude Code +9 - 0.406score
devops
Satcomx00-x00
CI/CD pipeline design and DevOps practices — GitHub Actions workflows, deployment strategies, infrastructure-as-code patterns, and observability basics.
SkillDFreshness: DClaude Code +9 - 0.406score
code-review
Satcomx00-x00
Code review standards and checklist — how to give constructive feedback, what to look for, and how to approve or request changes effectively.
SkillDFreshness: DClaude Code +9 - 0.406score
code-quality
Satcomx00-x00
Code quality mastery — programming principles (SOLID, DRY, KISS, YAGNI…), refactoring techniques, and design patterns to write clean, maintainable, extensible…
SkillDFreshness: DClaude Code +9
Cite this page
betterauth skill. Agent Mart. https://agentmart.dev/skills/satcomx00-x00-betterauth (last updated 2026-10-24)