PactDOCS

REFERENCE / BROWSER

window.pact

The framework-independent contract installed by the inline bootstrap and completed by pact.js.
01

Properties and methods

MemberTypeBehavior
readyPromise<void>Resolves when the active runtime is ready.
purposesPurposeDecisionsCurrent purpose map. Read true explicitly.
gpcbooleanWhether GPC restrictions are active.
regionstringCurrent resolved regional behavior.
decidedboolean | undefinedWhether a durable choice exists.
on('change', cb)() => voidSubscribe to committed decision changes.
on('open', cb)() => voidSubscribe to headless preference-open requests.
allow(purposes?)Promise | voidAllow selected purposes, subject to GPC.
deny(purposes?)Promise | voidDeny selected purposes.
setPreferences(map)Promise | voidCommit a complete custom preference edit.
openPreferences()Promise | voidOpen managed UI or notify a headless listener.
02

Subscribe safely

consent.ts
typescript
await window.pact.ready

const stop = window.pact.on('change', state => {
  syncOptionalFeatures(state.purposes)
})

// Later
stop()
TYPED WRAPPERUse pactClient