Offline
Store consent decisions in the browser with offline mode, perfect for sites without backend requirements
On this page
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
import {
ConsentManagerDialog,
ConsentManagerProvider,
CookieBanner,
} from '@c15t/react';
function App() {
return (
<ConsentManagerProvider options={{
mode: 'offline',
consentCategories: ['necessary', 'marketing'], // Optional: Specify which consent categories to show in the banner.
}}>
<div className="App">
{/* Your application content */}
</div>
<CookieBanner />
<ConsentManagerDialog />
</ConsentManagerProvider>
);
}
export default App;
How It Works
Info
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