Auth.js
Authentication for the Web.
Open Source. Full Stack. Own Your Data.
Sponsored by
Clerk complete user management
More than authentication...
Complete user management.
Easy
- Built in support for 77+ popular services
(Google, Facebook, Auth0, Apple…) - Use with any OAuth 2 or OpenID Connect provider
- Built in email / passwordless / magic link
- Use with any username / password store
Flexible
- Runtime agnostic, runs anywhere!
Vercel Edge Functions, Node.js, Serverless… - Use with any modern framework!
Next.js, SolidStart, SvelteKit… - Bring Your Own Database - or none!
MySQL, Postgres, MSSQL, MongoDB… - Choose database sessions or JWT
Secure
- Signed, prefixed, server-only cookies
- Built-in CSRF protection
- JWT with JWS / JWE / JWK
- Doesn't rely on client side JavaScript
Add authentication in minutes!
Next.js
// auth.ts
import NextAuth from "next-auth"
import GitHub from "next-auth/providers/github"
export const { auth, handlers } = NextAuth({ providers: [ GitHub ] })
// middleware.ts
export { auth as default } from "auth"
// app/api/auth/[...nextauth].ts
import { handlers } from "auth"
export const { GET, POST } = handlers
export const runtime = "edge"
SvelteKit /hooks.server.ts
import { SvelteKitAuth } from "@auth/sveltekit"
import GitHub from '@auth/core/providers/github'
import { GITHUB_ID, GITHUB_SECRET } from "$env/static/private"
export const handle = SvelteKitAuth({
providers: [
GitHub({
clientId: GITHUB_ID,
clientSecret: GITHUB_SECRET
})
],
})
SolidStart /routes/api/auth/[...solidauth].ts
import { SolidAuth } from "@auth/solid-start"
import GitHub from "@auth/core/providers/github"
export const { GET, POST } = SolidAuth({
providers: [
GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET
})
]
})
Auth.js is an open source community project.