Skip to content
Design System
GitHub

Runs a sensitive action and, when the server answers with a step-up code, holds it, opens the step-up dialog, and replays it once the person is verified.

    Replay

    Install
    npx shadcn add @syncrobotic/use-step-up

    Overview

    When to use

    • Every call the server may refuse with ELEVATED_SESSION_REQUIRED or TWO_FACTOR_SETUP_REQUIRED.

    Use something else

    Usage rules

    • Wrap the call, not the click: await stepUp.run(() => api.revokeKey(id)). Any other error passes through untouched.
    • Catch isStepUpCancelled(e) and say nothing happened; it is not a failure to report.
    • The codes are the server's contract (codes, setupCodes); read them with errorCodeOf, never from a message.
    • The replay runs once. If the server asks again, that error goes to the caller instead of a loop.

    Changelog

    • 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
    • 0.55.02026-11-27First release: run(action), triggered by ELEVATED_SESSION_REQUIRED and TWO_FACTOR_SETUP_REQUIRED (configurable), replays once after verify; cancel rejects with StepUpCancelledError. errorCodeOf reads code or the envelope's error.code, never the message.

    How to upgrade