local-pii

Get Started

Adapter-first privacy for Expo, React Native, the browser and Node.

local-pii protects personal information before it crosses the selected Generation provider boundary. A Detection adapter feeds the anonymizer, one privacy session owns a private conversation, and a native Generation adapter or inline callback calls the selected Generation model. Protected semantic content crosses the provider boundary; opaque reasoning, metadata, and options remain caller responsibility. The private mapping stays inside the caller's trust boundary.

import { createAnonymizer, token } from "local-pii"
import { rampartWeb } from "local-pii/web"
import { runInlineText } from "local-pii/inline"

const privacy = createAnonymizer({
  detection: rampartWeb(),
  placeholders: token(),
})
const conversation = privacy.createSession()
const answer = await runInlineText({
  session: conversation,
  input: "Email ana@acme.com",
  call: (protectedContent, { signal }) =>
    generationModel.generate(protectedContent, { signal }),
})

Rampart Q4 is a Detection model. Gemini Nano, Gemma, and provider models are Generation models. ner: remains a compatibility alias for detection:.

Install

bun add local-pii onnxruntime-web @local-pii/model-rampart

The quickstart uses browser Rampart, whose optional peers are onnxruntime-web and @local-pii/model-rampart. Deterministic Detection (emails, phones, cards, IBAN, SSN, IP, URLs) works with only local-pii in React Native, the browser, and Node.

Choose a Detection adapter

  • Expo / React Native → rampart() through onnxruntime-react-native.
  • Browser / web → rampartWeb() through onnxruntime-web (WASM/WebGPU).

Legacy ner: configuration is supported for migration, but new applications should use detection:.

Wrap a Generation call

On this page