usePIIMask Hook
React hook for masking PII with full control over output.
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>
);
}
| Option | Type | Default | Description |
|---|
mode | MaskMode | 'mask' | Masking mode |
detect | string[] | all | Run only these detectors |
disable | string[] | none | Disable these detectors |
| Property | Type | Description |
|---|
masked | string | The masked result |
tokenMap | Record<string, string> | Token → original map |
detections | string[] | Fired detector IDs |
restore | (masked: string) => string | Reverse tokenization |
Try it in the browser ↗