01
Wrap the application
pnpm add @pact/react @pact/runtimetsx
import { PactGate, PactProvider } from '@pact/react'
export function App() {
return (
<PactProvider siteKey="site_live_your_key" src="/pact.js" apiBase="/v1">
<PactGate purpose="analytics">
<Analytics />
</PactGate>
<YourApp />
</PactProvider>
)
}02
Read decisions with hooks
tsx
import { usePactPurpose } from '@pact/react'
export function AnalyticsGate() {
const allowed = usePactPurpose('analytics')
return allowed ? <Analytics /> : null
}03
Own the complete interface
Headless mode renders no Pact consent surface. State, GPC restrictions, evidence, and actions remain active.
tsx
function Root({ children }) {
return <PactProvider siteKey="site_live_your_key" mode="headless">
<PrivacyExperience />
{children}
</PactProvider>
}
function PrivacyExperience() {
const { decided, gpc, purposes, accept, reject, save } = usePact()
// Your components. Your CSS. Your motion.
}