Installation
ConsentLayer works in two parts: a banner script tag that handles the consent UI, and an optional SDK for programmatic access.
Banner Script (required)
Easiest: let your agent install it
Run claude mcp add consentlayer --transport http https://api.consentlayer.com/mcp
then ask: "Add the ConsentLayer banner to my site." Your agent will sign in,
provision the site, and write the script tag with your real key.
More on the MCP path →
Manual setup
-
Sign in to the dashboard and copy your project key.
-
Add this to the
<head>of every page — replace<your-key>with the value you copied. Don't includedeferorasync.<script src="https://b.consentlayer.com/<your-key>/banner.js"></script>
The banner handles consent collection, script blocking, and geo-detection. It writes a cl_consent cookie that the SDK reads.
SDK Package (optional)
Install the SDK for programmatic consent control in JavaScript or React apps:
npm install @consentlayer/sdkVanilla JavaScript
import { hasConsent, getConsentState, onConsentChange } from '@consentlayer/sdk'
// Check consent for a specific category
if (hasConsent('statistics')) {
loadAnalytics()
}
// Listen for consent changes
const unsub = onConsentChange((state) => {
console.log('Consent updated:', state.categories)
})React
import { ConsentLayerProvider, ConsentGate, useConsent } from '@consentlayer/sdk/react'
function App() {
return (
<ConsentLayerProvider>
<YourApp />
</ConsentLayerProvider>
)
}React is an optional peer dependency. Vanilla JS functions work without React installed.