A prototype implementation of passwordless authentication using SuperTokens magic links, Node.js, and Docker.
https://github.com/davidbmar/supertokens_nodejs · public · shipped
This project is a minimal demonstration of passwordless authentication. It uses SuperTokens to generate single-use magic links sent via email (logged to console for demo purposes). The architecture consists of a PostgreSQL database, the SuperTokens Core service, a Node.js Express backend, and a static HTML frontend served via npx serve.
docker-compose up -d npm start npx serve -s .
flowchart TD
User[User Browser]
Frontend[Static Frontend Server]
Backend[Node.js Express Backend]
SuperTokensCore[SuperTokens Core]
Database[PostgreSQL Database]
User --> Frontend
Frontend --> Backend
Backend --> SuperTokensCore
SuperTokensCore --> Database
The backend is built with Node.js and Express, integrating the supertokens-node SDK for session management and passwordless logic. The SuperTokens Core runs in a Docker container backed by PostgreSQL. The frontend is a vanilla HTML/JS application that interacts with the backend API for login requests and session verification.
sequenceDiagram
participant User
participant Frontend
participant Backend
participant SuperTokensCore
participant Database
User->>Frontend: Enter Email
Frontend->>Backend: POST /auth/signinup/code
Backend->>SuperTokensCore: Create Code
SuperTokensCore->>Database: Store Code
SuperTokensCore-->>Backend: Return Link Code
Backend->>Backend: Log Magic Link
Backend-->>Frontend: Success Response
User->>Frontend: Click Magic Link
Frontend->>Backend: GET /auth/signinup/code/consume
Backend->>SuperTokensCore: Consume Code
SuperTokensCore->>Database: Validate and Delete Code
SuperTokensCore-->>Backend: Session Tokens
Backend-->>Frontend: Set Cookies
Frontend-->>User: Show Dashboard
Use this repository as a reference implementation for integrating SuperTokens passwordless flow into a Node.js application. It demonstrates how to configure the core, override email delivery for testing, and handle frontend session states without a framework.