c15t
/
C15T Logo
Select a framework
Frameworks
Welcome to c15t Docs
Introduction to Consent Management (c15t)
AI Tools Integrations
OSS
Contributing to c15t.com
License
Building Privacy Tools in the Open
Legal
Cookie Policy
Privacy Policy
C15T Logo
HomeFrontendIntegrationsSelf HostChangelog
xbskydiscordgithub1.4k
c15t
/
C15T Logo
Select a framework
Frameworks
Welcome to c15t Docs
Introduction to Consent Management (c15t)
AI Tools Integrations
OSS
Contributing to c15t.com
License
Building Privacy Tools in the Open
Legal
Cookie Policy
Privacy Policy
home-2Docs
chevron-rightFrameworks
chevron-rightNext
chevron-rightComponents
chevron-rightClient-side-options

Client Side Options (App Dir)

Handle client-side options for the consent manager in Next.js App Directory.

In React some ConsentManagerProvider options including callbacks and scripts cannot be serialized and sent to the client from the server. This is why we have the ClientSideOptionsProvider component.

It is important to note that this component is not used in the Pages Directory. If you'd like to use a full client-side solution, you can use the <ConsentManagerProvider /> component from @c15t/nextjs/client.

Usage

app/consent-manager.client.tsx
'use client';

import { ClientSideOptionsProvider } from '@c15t/nextjs/client';
import { gtag } from '@c15t/scripts/google-tag';
import type { ReactNode } from 'react';

export function ConsentManagerClient({ children }: { children: ReactNode }) {
return (
	<ClientSideOptionsProvider
		scripts={[
			// Premade Google Tag script which you can use to load Google Analytics, Google Ads etc.
			gtag({
				id: 'G-XXXXXXXXXX',
				category: 'measurement',
			}),
		]}
		callbacks={{
			onBannerFetched(response) {
				console.log('onBannerFetched', response);
			},
			onConsentSet(response) {
				console.log('onConsentSet', response);
			},
			onError(response) {
				console.log('onError', response);
			},
		}}
	>
		{children}
	</ClientSideOptionsProvider>
);
}

Next, you should import this component to be inside your ConsentManagerProvider component.

app/consent-manager.tsx
import {
ConsentManagerDialog,
ConsentManagerProvider,
CookieBanner
} from '@c15t/nextjs';
import { ConsentManagerClient } from "./consent-manager.client";

export function ConsentManager({ children }: { children: React.ReactNode }) {
return (
	<ConsentManagerProvider
		options={{
			mode: 'c15t',
			backendURL: '/api/c15t',
			// ignoreGeoLocation: true, // Useful for development to always view the banner.
		}}
	>
		<CookieBanner />
    <ConsentManagerDialog />
		<ConsentManagerClient>
      {children}
    </ConsentManagerClient>
	</ConsentManagerProvider>
);
}

API Reference

ClientSideOptionsProviderProps

The main component accepts these props:

Available in other SDKs

C15T Logo
Leverage native React components for seamless integration and high performance in a robust Consent Management solution that empowers your development team while prioritizing privacy and compliance.
Product
  • Documentation
  • Components
Company
  • GitHub
  • Contact
Legal
  • Privacy Policy
  • Cookie Policy
c15t