Introduction
Headless password hook for React: show/hide, NIST-style strength, confirmation, server validation and leaked password checks.
Password fields are easy to get wrong: missing ARIA, a toggle that submits the form, a password manager that sees a text field, rules that differ between the form and the server. useViraPassword() handles this in one hook. Markup and styling stay yours.
Getting started
$ pnpm add @virastack/passwordComing from 1.0? Nothing breaks; see the release notes. Live demos are on the examples page.
Entry points
Only the root entry has "use client". The strength engine ships only when you pass a policy.
| Import | Exports | Runs on |
|---|---|---|
@virastack/password | useViraPassword (with or without React Hook Form), mergeProps, composeRefs, icons | client |
@virastack/password/strength | definePolicy, evaluate, normalizePassword | client + server |
@virastack/password/server | validatePassword (+ the strength exports) | server |
@virastack/password/pwned | checkPwned | server (recommended) |
Requirements
- React 18.2+ and
react-dom(React 19 supported) - No runtime dependencies
- React Hook Form is optional; any form library or none works.
Also selectable during ViraStack Start CLI setup (npx virastack@latest --tools password).
Why ViraStack Password?
- Headless: every returned value is a valid input or button prop.
- Radix-level details: hides on submit, focus returns after a click, controlled
visible, Caps Lock,autoComplete. - NIST-style strength: length first (15–64), common passwords, repeats and personal info. No composition rules by default.
- Same rules on the server: one policy object for the form and the Server Action.
- Error keys:
password.tooShort,password.mismatch… Messages and i18n stay yours.
Scope
- useViraPassword(), strength and confirm password
- React Hook Form, server validation and leaked passwords
- Accessibility and customization
Not included: a strength bar or password generator component, passkeys, clipboard clearing.