SuperTokens — Open Source Auth0 Alternative
SuperTokens is an open-source authentication solution with email/password, passwordless, social login, session management, and MFA. Drop-in UI components for React, Vue, and Angular.
这个资产会安全暂存
这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。
npx -y tokrepo@latest install 2da136b5-34c8-11f1-9bc6-00163e2b0d79 --target codex先暂存文件;激活前需要读取暂存 README 和安装计划。
What it is
SuperTokens is an open-source authentication solution that provides email/password login, passwordless authentication, social login (Google, GitHub, Apple, etc.), session management, and multi-factor authentication. It ships drop-in UI components for React, Vue, and Angular.
SuperTokens targets teams that want Auth0-level features without vendor lock-in or per-user pricing. You can self-host the core service or use their managed cloud.
How it saves time or tokens
Building authentication from scratch typically takes weeks and introduces security vulnerabilities. SuperTokens provides battle-tested flows for signup, login, password reset, email verification, and session management out of the box. The pre-built UI components mean you do not need to design login forms.
For AI-assisted development, SuperTokens' clear API surface and recipe-based architecture make it straightforward for LLMs to generate integration code.
Additionally, the project's well-structured documentation and active community mean developers spend less time troubleshooting integration issues. When AI coding assistants generate code for this tool, they can reference established patterns from the documentation, producing correct implementations with fewer iterations and lower token costs.
How to use
- Install the SDK for your backend and frontend:
# Backend (Node.js)
npm install supertokens-node
# Frontend (React)
npm install supertokens-auth-react
- Initialize SuperTokens in your backend:
const supertokens = require('supertokens-node');
const Session = require('supertokens-node/recipe/session');
const EmailPassword = require('supertokens-node/recipe/emailpassword');
supertokens.init({
supertokens: { connectionURI: 'http://localhost:3567' },
appInfo: { appName: 'MyApp', apiDomain: 'http://localhost:3001', websiteDomain: 'http://localhost:3000' },
recipeList: [EmailPassword.init(), Session.init()]
});
- Add the pre-built UI to your React app and SuperTokens handles the login flow.
- Protect API routes using the session verification middleware.
Example
// Protect an API route
const { verifySession } = require('supertokens-node/recipe/session/framework/express');
app.get('/api/protected', verifySession(), (req, res) => {
const userId = req.session.getUserId();
res.json({ message: 'Authenticated', userId });
});
Related on TokRepo
- AI Tools for Security — Security tools and authentication solutions
- AI Tools for Self-Hosted — Self-hostable alternatives to SaaS tools
Common pitfalls
- Running the SuperTokens core without persistent storage. The default in-memory mode loses all users on restart. Configure PostgreSQL or MySQL for production.
- Skipping CSRF protection for session-based auth. SuperTokens handles this automatically, but custom middleware can interfere if not configured correctly.
- Not setting up email verification. Users can sign up with invalid emails if email verification is disabled, leading to unrecoverable accounts.
- Failing to review community discussions and changelogs before upgrading. Breaking changes in major versions can disrupt existing workflows. Pin versions in production and test upgrades in staging first.
常见问题
SuperTokens is open-source and can be self-hosted, eliminating per-user pricing. Auth0 is a managed service with more enterprise features like SAML SSO and advanced analytics. SuperTokens covers the core auth flows (email/password, social, passwordless, MFA) and is sufficient for most applications.
Yes. SuperTokens provides a core service that runs as a Docker container or Java process. It stores user data in PostgreSQL or MySQL. Self-hosting gives you full data ownership and eliminates per-user costs. The managed cloud option is available for teams that prefer not to manage infrastructure.
SuperTokens provides pre-built UI components for React, Vue, and Angular via dedicated SDK packages. It also offers a headless mode where you build custom UI and call the SuperTokens API directly. Mobile SDKs are available for React Native, Flutter, and iOS/Android.
Yes. SuperTokens supports TOTP-based MFA that can be added to any login recipe. Users enroll via authenticator apps like Google Authenticator or Authy. MFA can be required for all users or enabled as an opt-in feature.
SuperTokens uses rotating refresh tokens with short-lived access tokens. Sessions are stored server-side and verified on each API request via middleware. The SDK handles token rotation, CSRF protection, and session revocation automatically.
引用来源 (3)
- SuperTokens GitHub— SuperTokens provides email/password, passwordless, social login, session managem…
- SuperTokens Documentation— Drop-in UI components for React, Vue, and Angular
- OWASP Authentication Guide— OAuth 2.0 and authentication best practices
讨论
相关资产
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.
Mattermost — Open Source Slack Alternative for Team Collaboration
Mattermost is an open-source messaging platform for secure team collaboration. Channels, threads, voice/video calls, playbooks, and integrations — self-hosted Slack alternative.
Rallly — Open Source Meeting Scheduling & Polling Tool
Rallly is an open-source Doodle alternative for scheduling group meetings. Create polls, share availability, and find the best time — no sign-up required for participants.
Twenty — Open-Source AI CRM (Salesforce Alternative)
Modern open-source CRM with AI features. Custom objects, kanban views, email sync, workflow automation. NestJS + React + PostgreSQL. AGPL-3.0, 43,700+ stars.