Skip to content
Back to skills

Authentication Logic

ASecurity

Guide to using Better Auth for client and server-side authentication.

  • 416 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 7, 2026
securitygonextjsapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add aiskillstore/marketplace --skill authentication-logic --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Authentication Logic?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Authentication Logic
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aiskillstore-authentication-logic/badge)](https://www.skillsdirectory.com/skills/aiskillstore-authentication-logic)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: authentication-logic
description: Guide to using Better Auth for client and server-side authentication.
---

# Authentication Logic

## Overview
We use **Better Auth** (`better-auth`) for identifying users.

## Config
- **Client**: `lib/auth-client.ts` exports `authClient`.
- **Server**: `lib/auth.ts` exports `auth`.

## Client-Side Usage
Use `authClient` for signing in, signing out, and checking session state in Client Components.

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

// Sign In
await authClient.signIn.email({
  email,
  password,
});

// Social Sign In
await authClient.signIn.social({
  provider: "google",
  callbackURL: "/onboarding", 
});

// Sign Out
await authClient.signOut();
```

## Server-Side Usage
Use `auth.api.getSession` for protecting API routes or Server Actions.

```ts
import { auth } from "@/lib/auth";
import { headers } from "next/headers";

const session = await auth.api.getSession({
  headers: await headers()
});

if (!session) {
  return new Response("Unauthorized", { status: 401 });
}
```

## AuthBar Component
- Located at `textbook/src/components/AuthBar/index.tsx`.
- Displays user avatar or login button.
- Fetches session from `/api/auth/session` (Next.js API route proxying Better Auth).

Files in this skill

  • SKILL.md1.2 KB
  • skill-report.json9.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…