Skip to main content
Looking for a hosted alternative?Try Clerk →
Sponsored

Open Source. Full Stack. Own Your Data.

Easy

Easy

  • Built in support for 85+ 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

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

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]/route.ts
import { handlers } from "auth"
export const { GET, POST } = handlers
export const runtime = "edge" // Optional
SvelteKit /hooks.server.ts
// src/auth.ts
import { SvelteKitAuth } from "@auth/sveltekit"
import GitHub from '@auth/sveltekit/providers/github'
import { GITHUB_ID, GITHUB_SECRET } from "$env/static/private"
export const { handle } = SvelteKitAuth({
providers: [
GitHub({
clientId: GITHUB_ID,
clientSecret: GITHUB_SECRET
})
],
})

// src/hooks.server.ts
export { handle } from "./auth"
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.