원클릭으로
authjs-knowledge-patch
Auth.js
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Auth.js
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
AlmaLinux
Angular
Arch Linux
Astro
AWS SDK
Axum
| name | authjs-knowledge-patch |
| description | Auth.js |
| license | MIT |
| version | 5.0.0 |
| metadata | {"author":"Nevaberry"} |
Use this patch to choose the maintained authentication path, avoid security-sensitive provider mistakes, and apply current Auth.js integration patterns. Read the topic reference before changing an affected flow; the quick reference below prioritizes breaking behavior, security updates, and common implementation work.
| Reference | Topics |
|---|---|
| Better Auth transition | Project status, choosing Auth.js or Better Auth, migration direction |
| Providers and authentication | Account linking, credentials errors, email providers, passkeys, OAuth customization, redirect proxies |
| Sessions and frameworks | Session lifecycle, Qwik, SvelteKit, Express |
| v5 migration | Next.js Pages Router limitations, Next.js 16 proxy protection |
| Adapters, operations, and security | Adapter contracts, value normalization, logging, security upgrade floors |
Audit installed package versions before debugging provider or adapter behavior.
| Package | Required action | Reason |
|---|---|---|
@auth/sveltekit | Upgrade to 1.11.1 or later | Pull in the Nodemailer security fix. |
next-auth v4 | Upgrade to 4.24.14 or configure the GitHub issuer explicitly | Accept GitHub callbacks containing the now-validated iss parameter. |
@auth/kysely-adapter | Upgrade to 1.11.2 and install kysely@^0.28.15 | Address CVE-2026-33468, an SQL-injection vulnerability. |
Read Adapters, operations, and security for exact upgrade implications.
With a database and multiple authentication methods, a later sign-in can link to an existing user when emails match. Evaluate the email-verification guarantee of every enabled provider; the weakest provider can undermine linking safety.
Do not assume matching email text alone proves common ownership. Read Providers and authentication before enabling a provider alongside existing accounts.
Returning null from authorize has two observable forms:
?error=CredentialsSignin&code=credentials.CredentialsSignin in form actions and custom server-side flows.CredentialsSignin to replace the public, URL-visible code; keep the value generic enough to avoid leaking sensitive details.class InvalidLoginError extends CredentialsSignin {
code = "invalid_credentials"
}
Credentials({
async authorize(credentials) {
const user = await authenticate(credentials)
if (!user) throw new InvalidLoginError()
return user
},
})
Treat passkeys as experimental. Before enabling them:
Authenticator table.@simplewebauthn/server@9.0.3.Passkey provider and set experimental.enableWebAuthn to true.@simplewebauthn/browser@9.0.1 and import signIn from next-auth/webauthn.export default {
adapter: PrismaAdapter(prisma),
providers: [Passkey],
experimental: { enableWebAuthn: true },
}
Register a passkey only for an authenticated user; omit the action for ordinary sign-in.
import { signIn } from "next-auth/webauthn"
await signIn("passkey", { action: "register" })
await signIn("passkey")
Use the built-in sign-in page when possible because it exposes the configured passkey action automatically. Check the package floors in Providers and authentication.
url template variable, and configure both the API key and transactional ID.type: "email", implement sendVerificationRequest, and use the provider id when initiating sign-in.User fields from profile().Account fields with account().[customFetch] option to scope proxying to one provider.RedirectProxyUrl with Apple; select another callback strategy.Read Providers and authentication before changing profile persistence or transport behavior.
A local adapter may implement the methods required by enabled flows. An officially distributed adapter must implement the complete Adapter interface.
| Enabled flow | Required methods |
|---|---|
| User/account management | createUser, getUser, getUserByAccount, updateUser, linkAccount |
| Database sessions | createSession, getSessionAndUser, updateSession, deleteSession |
| Passwordless email | getUserByEmail, createVerificationToken, useVerificationToken |
Do not build a local flow around deleteUser or unlinkAccount; Auth.js does not currently invoke them. Normalize database-native values to plain JavaScript objects in both directions, including values stored in custom fields. Read Adapters, operations, and security.
Session row to be deleted when Auth.js reads it.| Framework | Read session | Sign in or out |
|---|---|---|
| Qwik server | event.sharedMap.get("session") | Use the actions returned by useSignIn() and useSignOut() in <Form> or call .submit(). |
| Qwik client | useSession() | Submit providerId and options.redirectTo for sign-in; submit redirectTo for sign-out. |
| SvelteKit server | event.locals.auth() after installing the Auth.js handle | Wire signIn or signOut to matching default form actions. |
| SvelteKit client | Return the server session through page data | Import the client handlers from @auth/sveltekit/client. |
| Express | getSession(req) | Call signIn(req, res) or signOut(req, res) from application-owned routes. |
For Next.js 16, export Auth.js auth as proxy from proxy.ts; keep middleware.ts and the middleware export on older Next.js versions. The proxy matcher chooses the covered routes, and the authorized callback decides whether the request proceeds.
// proxy.ts
export { auth as proxy } from "@/auth"
// auth.ts
export const { auth, handlers } = NextAuth({
callbacks: {
authorized: async ({ auth }) => !!auth,
},
})
Do not expect restored server-side session helpers in Pages Router API routes; fetch the session REST endpoint there. Continue to call auth(ctx) from getServerSideProps. Read v5 migration.
When supplying custom logger handlers, route debug output through logger.debug. The separate debug option is ignored once a custom logger is present.
NextAuth({
logger: {
error: (code, ...message) => log.error(code, message),
warn: (code, ...message) => log.warn(code, message),
debug: (code, ...message) => log.debug(code, message),
},
})