Skip to content

MFA with React#478

Open
msaldivar wants to merge 15 commits intosupertokens:masterfrom
msaldivar:mfa-react
Open

MFA with React#478
msaldivar wants to merge 15 commits intosupertokens:masterfrom
msaldivar:mfa-react

Conversation

@msaldivar
Copy link
Contributor

Related Issue

Link to Google Doc

https://docs.google.com/document/d/19fwmOsrD9x9eRjhS2s7dc6hSiZ4Kmk9sy4_pbH3Ny-I/edit?tab=t.0

Checklist

  • Has cover image been added
  • Have all content images been added. Do they render correctly? (aspect ratio etc)
  • Cover images and filenames use hyphens (-) instead of en/em dashes (–/—)
  • The code inside code blocks gives no errors
  • Check for SEO keyword?
  • Added call to action to link to supertokens and to link to other blogs.
  • Add reference to how SuperTokens solves this blog's problem (if relevant).

Remaining TODOs

  • ...

@netlify
Copy link

netlify bot commented Feb 9, 2026

Deploy Preview for gracious-clarke-e6b312 ready!

Name Link
🔨 Latest commit 332e7f8
🔍 Latest deploy log https://app.netlify.com/projects/gracious-clarke-e6b312/deploys/69a6b0cc390f37000848e47c
😎 Deploy Preview https://deploy-preview-478--gracious-clarke-e6b312.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Collaborator

@jscyo jscyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the accuracy of the content. I've pointed out some of the issues

---
title: Add MFA to React Fast with SuperTokens
description: "Secure your React app with multi-factor authentication in minutes. Learn MFA options, setup steps, and best practices using SuperTokens."
date: "02/20/2026"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date format is incorrect. Please check the deploy preview to see if the blog is rendering properly.

Comment on lines +100 to +112
```javascript
import MultiFactorAuth from "supertokens-node/recipe/multifactorauth";
import TOTP from "supertokens-node/recipe/totp";

recipeList: [
EmailPassword.init(),
TOTP.init(),
MultiFactorAuth.init({
firstFactors: ["emailpassword"],
}),
Session.init()
]
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do check the functionality of this code, or refer to the documentation. You are initializing the Email password recipe here and its not been importeed

]
```

**4. Wire the Frontend SDK**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show the snippet for initializing the frontend SDK, you need to show the recipes being initialized here


**5. Protect Routes with SessionAuth**

Wrap protected components with `SessionAuth`. The wrapper checks session validity and MFA completion before rendering children. Incomplete sessions redirect to the appropriate challenge screen.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add snippets for all of this. Just writing this without showing does not make sense


**6. Test Token Rotation and Theft Detection**

Verify that refresh tokens rotate on each use and that concurrent token usage triggers theft detection. SuperTokens automatically revokes sessions when replay attacks are detected.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have not explained how you can actually test this out in this section


**Rotate Refresh Tokens on Every Use**

Single-use refresh tokens nullify stolen credentials. If an attacker captures a refresh token, the next legitimate refresh invalidates it. SuperTokens enables rotation by default, detecting when both parties attempt to use the same token.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. Please refer to SuperTokens Rotating Refresh Token strategy with Access and Refresh Tokens


**Log Token Theft Detection Events**

When SuperTokens detects refresh token reuse, it fires `onTokenTheftDetected`. Pipe these events to your SIEM or monitoring system. Token theft attempts indicate active attacks against your users, not just background noise.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants