Offline Mode
Store consent decisions in the browser with offline mode, perfect for sites without backend requirements
The offline mode provides a simple, browser-based approach to storing user consent decisions without requiring a backend server.
Key Characteristics
- No backend required - Everything is stored locally in the browser
- Simplified setup - Get started quickly with minimal configuration
- Independence - Works without external services or APIs
- Fast implementation - Ideal for prototyping and simpler sites
Implementation
Configure the Client (Svelte/JavaScript)
Set up the c15t client with offline mode in your Svelte or JavaScript project:
Use the Consent Manager in Your App
You can now use the consentManager
instance in your Svelte components or JavaScript code:
How It Works
Offline mode provides the same API interface as the standard client but operates completely client-side.
The offline mode implements the same interface as the standard client, but with the following differences:
- Storage: All consent preferences are stored in the browser's localStorage using the configured key
- Network: No network requests are made, all operations happen locally
- Consent Banner: The banner visibility is determined by checking if a value exists in localStorage
- Consent Verification: Always returns a successful response
Configuration Options
The offline mode accepts the following configuration options:
Storage Mechanisms
In offline mode, consent decisions are stored in the browser using:
LocalStorage
By default, c15t uses the browser's localStorage to persist consent decisions:
SessionStorage
For session-based consent that's cleared when the browser is closed:
Memory Only
For applications where persistence isn't needed:
Browser Compatibility
Some browser environments like private browsing modes may have localStorage restrictions.
The offline mode relies on localStorage, which is supported in all modern browsers. However, it includes fallbacks for environments where localStorage might be unavailable or restricted:
- Private browsing modes in some browsers
- Cookie-blocking browser extensions
- Browsers with storage permissions disabled
In these cases, the client will log a warning and continue functioning with defaults.
Use Cases
Development and Testing
Offline mode is perfect for development and testing environments where you don't want to set up a backend:
Static Sites
Offline mode is an excellent choice for static sites deployed on platforms like Vercel, Netlify, or GitHub Pages.
For static sites without backend integration, offline mode provides a simple solution:
Fallback Mode
You can use offline mode as a fallback when the backend is unavailable:
Limitations
Understand these limitations when deciding if offline mode is right for your application.
While offline mode provides a functional consent management solution, it has some limitations:
- No Centralized Reporting: Since all data is stored locally, you can't generate reports or analytics
- Device-Specific: Consent preferences don't transfer between devices or browsers
- Storage Limits: localStorage has size limitations (typically 5-10MB per domain)
- No Server-Side Logic: Custom server-side processing of consent isn't possible
When to Use Offline Mode
Consider using offline mode when:
- You're building a prototype or MVP
- Your site doesn't have a backend
- You want the simplest possible implementation
- Cross-device synchronization isn't a requirement
- You have limited compliance needs
For more complex applications or those with stricter compliance requirements, consider Server-Based Storage instead.