🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@sentinel-password/react

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentinel-password/react

React hook (usePasswordValidator) for @sentinel-password/core - password validation made simple

latest
Source
npmnpm
Version
1.3.9
Version published
Weekly downloads
5.2K
4.3%
Maintainers
1
Weekly downloads
 
Created
Source

@sentinel-password/react

npm version TypeScript License: MIT

React hook for password validation using @sentinel-password/core. Provides debounced validation with full TypeScript support.

Documentation | Interactive Playground | API Reference

Features

  • usePasswordValidator hook - Debounced password validation with configurable delay
  • TypeScript-First - Full type safety with strict mode
  • Lightweight - Minimal wrapper around @sentinel-password/core
  • React 18 & 19 - Supports both React 18 and 19

Installation

@sentinel-password/core is a regular dependency of this package (not a peer), so installing @sentinel-password/react automatically pulls in core. You only need to add it explicitly if you're importing from core directly elsewhere in your app.

npm install @sentinel-password/react
# or
pnpm add @sentinel-password/react
# or
yarn add @sentinel-password/react

Peer dependencies: React 18 or 19 — bring your own.

Quick Start

import { usePasswordValidator } from '@sentinel-password/react'

function PasswordForm() {
  const { password, setPassword, result, isValidating } = usePasswordValidator({
    debounceMs: 300,
    minLength: 10,
    requireUppercase: true,
  })

  return (
    <div>
      <input
        type="password"
        value={password}
        onChange={(e) => setPassword(e.target.value)}
        placeholder="Enter password"
      />
      {isValidating && <span>Validating...</span>}
      {result && (
        <div>
          <p>Strength: {result.strength}</p>
          {result.feedback.suggestions.map((s, i) => (
            <p key={i}>{s}</p>
          ))}
        </div>
      )}
    </div>
  )
}

API

usePasswordValidator(options?)

Returns an object with:

PropertyTypeDescription
passwordstringCurrent password value
setPassword(password: string) => voidUpdate the password. Whether validation also fires depends on debounceMs / validateOnChange — see those rows below. In manual mode (debounceMs: 0 + validateOnChange: false) this only updates state; call validate() to evaluate.
resultValidationResult | undefinedValidation result (undefined until first validation)
isValidatingbooleanWhether validation is in progress (during debounce)
validate() => voidManually trigger validation
reset() => voidReset password and validation state

Options

Extends all @sentinel-password/core options plus:

OptionTypeDefaultDescription
debounceMsnumber300Debounce delay in ms (0 to disable)
initialPasswordstring''Seed value for the hook's password state. Use this together with validateOnMount to validate a pre-filled value (e.g. edit-profile flows) on first render. The input stays fully controlled by setPassword afterwards.
validateOnMountbooleanfalseValidate the seed value (see initialPassword) once on mount. Skips empty values, so it's a no-op when initialPassword is empty or omitted.
validateOnChangebooleanfalseOnly matters when debounceMs === 0: true validates synchronously on every change, false disables automatic validation (call validate() manually). With the default debounceMs > 0, debounced validation runs on every change regardless of this flag.

License

MIT © Aleksei Kankov

Keywords

password

FAQs

Package last updated on 19 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts