Skills2026年4月10日·1 分钟阅读

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 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 29/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Stage only
信任
信任等级:Established
入口
step-1.md
安全暂存命令
npx -y tokrepo@latest install 2da136b5-34c8-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
Open-source Auth0 alternative with email/password, passwordless, social login, session management, and MFA for React, Vue, Angular.
§01

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.

§02

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.

§03

How to use

  1. Install the SDK for your backend and frontend:
# Backend (Node.js)
npm install supertokens-node

# Frontend (React)
npm install supertokens-auth-react
  1. 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()]
});
  1. Add the pre-built UI to your React app and SuperTokens handles the login flow.
  1. Protect API routes using the session verification middleware.
§04

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 });
});
§05

Related on TokRepo

§06

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.

常见问题

How does SuperTokens compare to Auth0?+

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.

Can I self-host SuperTokens?+

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.

Which frontend frameworks does SuperTokens support?+

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.

Does SuperTokens support multi-factor authentication?+

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.

How does SuperTokens handle session management?+

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)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产