RecoveryCodes
One-time backup codes, blurred until revealed. Copy or download them in one press; Continue unlocks only after the person confirms they stored them. Auth.
Open playgroundYour recovery codes
Each code works once if you lose your device. Keep them somewhere only you can reach.
Reveal the codes to continue.
About
RecoveryCodes is a React component in the Auth category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { RecoveryCodes } from "@ashutoshswamy/smoui" and set codes, onConfirm, filename.
Install
npm i @ashutoshswamy/smouiUsage
import { RecoveryCodes } from "@ashutoshswamy/smoui";
<RecoveryCodes codes={["7k2f-9qxa", "m3vd-81lp", "c9tz-4hre", "w5ns-d20b"]} onConfirm={() => api.enableTwoFactor()} />Props 3
- codes
The codes to show.
string[]- onConfirm
Runs on Continue. A promise shows a busy state.
() => void | Promise<unknown>- filename
Name of the downloaded file. Default recovery-codes.txt.
string
More auth components
- AccountSwitcherPick which signed-in account to use. One highlight stretches to the chosen row, arrow keys move the choice, and the radio semantics are real.
- ApiKeyFieldA secret kept out of sight. The prefix and last four characters stay readable; Reveal decodes the rest left to right and a bar counts down to when it masks itself again.
- ConsentCardOAuth-style consent. Each permission is a row you can untick unless it is required, and the allow button counts what you are granting.
- DeviceApprovalThe "was this you?" card for a sign-in from a new device. The two answers are equal-weight buttons, the pressed one shows a spinner, and the card settles into a tick or a shield.
- MagicLinkFormPasswordless sign-in. Enter an email and the form hands over to a check-your-inbox card with a drawn tick, a resend countdown and a way back to fix a typo.
- PasskeyButtonContinue with passkey. While the device prompt is open, rings ripple out of the badge; a recognised passkey becomes a drawn tick, a refusal a cross. The label follows each state.