Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By ramonmalcolm10MIT
Lets you add sessions, password hashing and 2FA to JS apps with the ideal-auth library. It claims zero framework dependencies and connects through a cookie bridge you wire to your framework.
Trending plugins
7-day copy clicks
Claude loads one when your task matches it, or you run it by name.
Executables (bin/) — files in this plugin's bin/ directory are added to the Bash tool's PATH while the plugin is enabled.
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Auth primitives for the JS ecosystem. Zero framework dependencies. Inspired by Laravel's Auth and Hash facades.
Provide a cookie bridge (3 functions) once during setup, and auth().login(user) just works — handles session creation, cookie encryption, and storage internally via iron-session.
bun add ideal-auth
# IDEAL_AUTH_SECRET (required — used by createAuth)
bunx ideal-auth secret
# IDEAL_AUTH_SECRET=aLThikMgJKMBB5WZLE-lCaOQUdgPWU8BHRv99bkYaVY
# Encryption key (optional — used by encrypt/decrypt for data at rest)
bunx ideal-auth encryption-key
# ENCRYPTION_KEY=9546dd9fa461ce15f0aacd6e1b461b52
Copy the output into your .env file. IDEAL_AUTH_SECRET must be at least 32 characters. ENCRYPTION_KEY is only needed if you use encrypt()/decrypt() (e.g., encrypting TOTP secrets or access tokens at rest).
// lib/auth.ts
import { createAuth, createHash } from 'ideal-auth';
import { cookies } from 'next/headers';
import { db } from '@/lib/db';
export const hash = createHash({ rounds: 12 });
export const auth = createAuth({
secret: process.env.IDEAL_AUTH_SECRET!, // 32+ characters
cookie: {
get: async (name) => (await cookies()).get(name)?.value,
set: async (name, value, opts) => (await cookies()).set(name, value, opts),
delete: async (name) => (await cookies()).delete(name),
},
hash,
resolveUser: async (id) => {
return db.user.findUnique({ where: { id } });
},
resolveUserByCredentials: async (credentials) => {
return db.user.findUnique({ where: { email: credentials.email } });
},
});
// Server Action
'use server';
import { auth } from '@/lib/auth';
// Call auth() once per request and reuse the instance — it caches the
// session payload and user, so subsequent calls avoid redundant work.
const session = auth();
// Login with credentials (password verified automatically)
const success = await session.attempt({ email, password });
// Login with a user object directly
await session.login(user);
// Login by user ID
await session.loginById('user-123');
// Check session
const isLoggedIn = await session.check();
const currentUser = await session.user();
const userId = await session.id();
// Logout
await session.logout();
createAuth(config)Returns a function auth(options?) that creates an AuthInstance on each call. Pass { autoTouch: true } to enable automatic session extension for that request.
const session = auth(); // default — read-only check/user/id
const session = auth({ autoTouch: true }); // auto-extends session past halfway on check/user/id
| Field | Type | Required | Default |
|---|---|---|---|
secret | string | Yes | — |
cookie | CookieBridge | Yes | — |
resolveUser | (id: string) => Promise<User | null | undefined> | Yes (unless sessionFields is provided) | — |
sessionFields | (keyof User & string)[] | Yes (unless resolveUser is provided) | — |
validateSession | (session: SessionInfo) => boolean | Promise<boolean> | No | — . Server-side revocation check, run once per request on the first session read. See Revoking sessions. |
hash | HashInstance | No | — |
resolveUserByCredentials | (creds: Record<string, any>) => Promise<AnyUser | null | undefined> | No | — |
credentialKey | string | No | 'password' |
passwordField | string | No | 'password' |
attemptUser | (creds: Record<string, any>) => Promise<User | null | undefined> | No | — |
session.cookieName | string | No | 'ideal_session' |
session.maxAge | number (seconds) | No | 604800 (7 days) |
session.rememberMaxAge | number (seconds) | No | 2592000 (30 days) |
session.autoTouch | boolean | No | false. Auto-extend sessions past halfway on check()/user()/id(). Enable for Express/Hono. Disable for Next.js. |
session.cookie | Partial<ConfigurableCookieOptions> | No | secure in prod, sameSite lax, path / (httpOnly is always true — not configurable) |
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
Plugins from other owners that cover similar ground
Generated from the plugin's indexed repository (ramonmalcolm10/ideal-auth) — no native marketplace selected
npx claudepluginhub p/ramonmalcolm10-ideal-auth