Read sessions client- and server-side, guard routes, and run sign in/up/out with Better Auth. Use when gating pages/APIs on auth or wiring auth flows.
Ships in andrelandgraf-fullstackrecipes. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Read sessions, protect routes, and run sign in/up/out with Better Auth.
Complete these setup recipes first:
Use the auth client hooks from @/lib/auth/client in client components.
"use client";
import { useSession, signOut } from "@/lib/auth/client";
export function UserMenu() {
const { data: session, isPending } = useSession();
if (isPending) return <div>Loading...</div>;
if (!session) return <a href="/sign-in">Sign In</a>;
return (
<div>
<span>{session.user.name}</span>
<button onClick={() => signOut()}>Sign Out</button>
</div>
);
}
In Server Components and API routes, call auth.api.getSession with the request headers.
import { auth } from "@/lib/auth/server";
import { headers } from "next/headers";
const session = await auth.api.getSession({ headers: await headers() });
if (!session) {
return new Response("Unauthorized", { status: 401 });
}
// session.user.id for queries...
Redirect unauthenticated users away from protected pages, and authenticated users away from auth pages.
import { redirect } from "next/navigation";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
export default async function ProtectedPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) redirect("/sign-in");
return <Dashboard user={session.user} />;
}
export default async function SignInPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (session) redirect("/chats");
return <SignIn />;
}
After validating the session, fetch user-specific data in parallel.
const [chats, profile] = await Promise.all([
getUserChats(session.user.id),
getUserProfile(session.user.id),
]);
import { signIn, signUp, signOut } from "@/lib/auth/client";
await signIn.email({ email, password, callbackURL: "/chats" });
await signIn.social({ provider: "google", callbackURL: "/chats" });
await signUp.email({ email, password, name, callbackURL: "/verify-email" });
await signOut({
fetchOptions: { onSuccess: () => router.push("/") },
});
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
12 skills in this plugin
/analytics-best-practicesTrack custom events and conversions with Vercel Web Analytics via the track() call. Use when instrumenting user actions, conversions, or form submissions./drizzle-queriesWrite type-safe Postgres queries with Drizzle ORM (select/insert/update/delete, relations, new tables). Use when querying or mutating the database or adding a Drizzle table./logging-best-practicesEmit structured logs with Pino (levels, context-first signature, workflow-safe step wrapper). Use when adding logging to routes, libraries, or workflows./og-image-generationGenerate dynamic social preview images using Next.js file conventions and the next/og library. Server-rendered JSX images cached at build time./ralph-loop-workflowRun a coding agent in an autonomous loop via a /ralph command, gated by a preflight check that every CLI is installed, linked, and authenticated. Use when driving long-running autonomous development from a wide, outcome-focused prompt./sentry-best-practicesCapture exceptions, attach user/context, add spans and breadcrumbs, and log via the Sentry SDK. Use when instrumenting errors, performance, or context in app code./andrelandgraf-fullstackrecipes:authentication-best-practicesfrom andrelandgraf-fullstackrecipes
andrelandgraf-fullstackrecipes@cascade-code-general-misc-3 is listed by joshuarweaver/cascade-code-general-misc-3 — review the source before installing
npx claudepluginhub joshuarweaver/cascade-code-general-misc-3 --plugin andrelandgraf-fullstackrecipesOther plugins' skills for the same job