SDK Overview
Open-source consent SDK — headless core, React hook, cloud adapter, and a CLI scaffolder.
The Consentify SDK is a set of npm packages for managing cookie consent programmatically. All SDK packages are open-source under MIT license.
Packages
| Package | Purpose | Version |
|---|---|---|
@consentify/core | Headless consent state, cookie storage, policy versioning, typed events, GCM v2 | 2.3.x |
@consentify/react | React hook (useConsentify) for reactive state | 2.1.x |
@consentify/cloud | Cloud adapter - posts events to Consentify dashboard | 1.0.x |
create-consentify | Interactive CLI scaffolder | 0.1.x |
Quick Start — CLI
The fastest way to add Consentify to an existing project:
npx create-consentify@latestThe CLI prompts for framework (Next.js App/Pages, Vite + React, Remix, Astro, vanilla), consent categories, opt-in vs opt-out mode, and optional Google Consent Mode v2 wiring. It installs the right packages and writes a lib/consent.ts + provider component for your stack.
Quick Start — Manual
// lib/consentify.ts
import { createConsentify } from '@consentify/core';
import { enableCloud } from '@consentify/cloud';
export const consentify = createConsentify({
policy: { categories: ['analytics', 'marketing'] as const },
});
enableCloud(consentify, {
siteId: process.env.NEXT_PUBLIC_CONSENTIFY_SITE_ID!,
apiKey: process.env.NEXT_PUBLIC_CONSENTIFY_API_KEY,
});// components/consent-banner.tsx
'use client';
import { useConsentify } from '@consentify/react';
import { consentify } from '@/lib/consentify';
export function ConsentBanner() {
const state = useConsentify(consentify);
if (state.decision === 'decided') return null;
return (
<div role="dialog" aria-label="Cookie consent">
<p>We use cookies to improve your experience.</p>
<button onClick={() => consentify.acceptAll()}>Accept All</button>
<button onClick={() => consentify.rejectAll()}>Reject All</button>
</div>
);
}Integration Paths
| Script Tag | SDK (npm) | Shadcn Registry | |
|---|---|---|---|
| Best for | Any website, no-code | React/Next.js developers | Full UI ownership |
| Setup | One <script> tag | npm install + config | npx shadcn add |
| Customization | Data attributes + dashboard | Full programmatic control | Edit source code directly |
| Cloud Analytics | Built-in | Optional via @consentify/cloud | Pre-configured |
| UI | Auto-rendered banner | Build your own or use @consentify/react | Pre-built React component |
When to Use the SDK
- You're building a React/Next.js app and want consent integrated into your component tree
- You need programmatic control over consent state (conditional script loading, Google Consent Mode v2)
- You want to build a custom consent UI instead of using the default widget
- You need policy versioning to auto-invalidate consent when categories change
When to Use the Script Tag Instead
- Simple HTML/CSS sites with no build tools
- WordPress or other CMS platforms
- You just want drop-in consent with zero code