Cookie Consent Service
Component Detail
Service Layer
medium complexity
Shared Component
frontend
0
Dependencies
1
Dependents
0
Entities
0
Integrations
Description
Lightweight client-side service managing consent state persistence, providing a Consent API that embedded scripts and third-party integrations query before executing. Ensures GDPR and ePrivacy Directive compliance by blocking analytics and marketing scripts until the relevant category is accepted.
cookie-consent-service
Responsibilities
- Read and write consent state from localStorage
- Expose Consent API for scripts to query consent before executing
- Block analytics and marketing scripts until consent is granted
- Notify script loaders when consent state changes
- Validate consent state integrity on each page load
Interfaces
getConsent(): ConsentState
setConsent(categories: ConsentCategories): void
hasConsent(category: string): boolean
onConsentChange(callback: (state: ConsentState) => void): void
revokeConsent(category: string): void
resetConsent(): void
isFirstVisit(): boolean