Core Documentation
Comprehensive guide to using the c15t package for managing privacy consents.
Introduction
The c15t
package is a powerful headless library that transforms privacy consent management into a fully observable system. Built with modern web applications in mind, it provides a robust foundation for implementing privacy-compliant consent management while giving developers complete control over the user interface.
Key Features
- 🎯 Zero UI Dependencies: A truly headless solution that doesn't impose any UI constraints
- ⚡️ High Performance: Optimized state management with minimal overhead
- 🔄 Real-time Updates: Instant state synchronization across your application
- 🛡️ Type-safe: Built with TypeScript for enhanced developer experience
- 📦 Lightweight: Small bundle size with zero dependencies
- 🔌 Framework Agnostic: Works with any JavaScript framework or vanilla JS
Why Use c15t?
- Headless Architecture: Provides the core logic and state management for consent without imposing any UI constraints, allowing developers to build custom interfaces tailored to their application's needs.
- Custom UI Development: Perfect for teams that want to design their own consent interfaces while leveraging robust backend logic.
- Flexibility and Control: Offers complete control over how consents are displayed and managed, enabling seamless integration with existing systems and workflows.
Installation
To install the package, use one of the following commands:
Basic Setup
To create a consent manager store, import and use the createConsentManagerStore
function. This store will handle all consent-related state and logic:
State Management
The store provides several methods to manage consent states:
Best Practices
-
Early Initialization: Initialize the consent manager as early as possible in your application lifecycle.
-
Consent Persistence: Always handle consent persistence properly:
Example Implementation using Vanilla JavaScript
This is a basic example of how to implement the consent manager store to create a cookie banner using vanilla JavaScript.
Use Cases
- Custom Consent UI: Use the core library to manage consent logic while building a custom UI that matches your application's design language.
- Integration with Analytics: Seamlessly integrate consent management with analytics tools to ensure compliance with privacy regulations.
- Dynamic Consent Management: Adjust consent options dynamically based on user location or preferences, using the library's flexible API.
Managing Consents
You can manage user consents using various methods provided by the store:
Update consent for a specific type.