# Logto — Open Source Authentication & Authorization for SaaS > Logto is an open-source Auth0 alternative providing OIDC/OAuth 2.1 authentication with multi-tenancy, SSO, RBAC, and MFA for modern SaaS and AI apps. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash docker run --name logto -p 3001:3001 -p 3002:3002 -e DB_URL=postgres://postgres:password@host.docker.internal:5432/logto ghcr.io/logto-io/logto:latest ``` Open `http://localhost:3002` (Admin Console) — set up your first application and sign-in experience. ## Intro **Logto** is an open-source authentication and authorization platform built on OIDC and OAuth 2.1 standards. It provides a complete identity infrastructure for SaaS applications with multi-tenancy, social login, SSO, MFA, and role-based access control out of the box. With 11.9K+ GitHub stars and MPL-2.0 license, Logto offers both self-hosted and cloud options, making it a viable alternative to Auth0, Clerk, and Firebase Auth with full data ownership. ## What Logto Does Logto handles the entire authentication and authorization lifecycle: - **Sign-in Experience**: Customizable login pages with email/password, phone OTP, social login (Google, GitHub, Apple, etc.), and passwordless options - **Multi-tenancy**: Organizations with member management, invitation flows, and per-org settings - **Single Sign-On (SSO)**: Enterprise SSO with SAML and OIDC federation for connecting corporate identity providers - **Access Control**: Role-based access control (RBAC) with API resource permissions and organization-level roles - **Multi-factor Authentication**: TOTP authenticator apps, WebAuthn/passkeys, and backup codes ## Architecture ``` ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ Your App │────▶│ Logto Core │────▶│ PostgreSQL │ │ (SDK) │ │ (OIDC/OAuth)│ │ (Users/Orgs)│ └──────────────┘ └──────┬───────┘ └──────────────┘ │ ┌──────┴───────┐ │ Admin Console│ │ (React SPA) │ └──────────────┘ ``` ## Integration Example (Next.js) ```bash npm install @logto/next ``` ```typescript // app/api/logto/[action]/route.ts import { handleSignIn, handleSignOut, handleCallback } from '@logto/next/server-actions'; import { logtoConfig } from './config'; export { handleSignIn, handleSignOut, handleCallback }; // logto.config.ts export const logtoConfig = { endpoint: 'http://localhost:3001', appId: 'your-app-id', appSecret: 'your-app-secret', baseUrl: 'http://localhost:3000', cookieSecret: 'your-cookie-secret', cookieSecure: process.env.NODE_ENV === 'production', }; ``` ```tsx // app/page.tsx import { getLogtoContext } from '@logto/next/server-actions'; export default async function Home() { const { isAuthenticated, claims } = await getLogtoContext(logtoConfig); return isAuthenticated ? (