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.
Safe staging for this asset
This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.
npx -y tokrepo@latest install 2da136b5-34c8-11f1-9bc6-00163e2b0d79 --target codexStages files first; activation requires review of the staged README and plan.
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.
Frequently Asked Questions
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.
Citations (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
Related on TokRepo
Discussion
Related Assets
OpenSSF Scorecard — Security Health Metrics for Open Source
OpenSSF Scorecard automatically assesses open source projects against a set of security best practices, producing a score that helps maintainers and consumers understand supply chain risk.
draw.io — Free Open-Source Diagramming Tool for Any Platform
draw.io is a free, browser-based diagramming application that supports flowcharts, UML, network diagrams, and more. Works offline as a desktop app on Windows, macOS, and Linux with no account required.
Coturn — Open Source TURN and STUN Server for WebRTC
A free, open-source TURN and STUN server implementation that provides NAT traversal for WebRTC, VoIP, and real-time communication applications.
Gatsby — React-Based Framework for Performant Static Sites
Gatsby is a React-based open-source framework for building fast, secure websites and apps. It combines static site generation with dynamic capabilities, pulling data from any source via GraphQL.