pii-mask

usePIIMask Hook

React hook for masking PII with full control over output.

Usage

import { usePIIMask } from '@pii-mask/react';

function MaskedEmail({ email }: { email: string }) {
  const { masked, detections, restore } = usePIIMask(email, {
    mode: 'tokenize',
  });

  return (
    <div>
      <p>Masked: {masked}</p>
      <p>Detections: {detections.join(', ')}</p>
      <button onClick={() => console.log(restore(masked))}>Reveal</button>
    </div>
  );
}

Options

OptionTypeDefaultDescription
modeMaskMode'mask'Masking mode
detectstring[]allRun only these detectors
disablestring[]noneDisable these detectors

Return value

PropertyTypeDescription
maskedstringThe masked result
tokenMapRecord<string, string>Token → original map
detectionsstring[]Fired detector IDs
restore(masked: string) => stringReverse tokenization

Try it in the browser ↗