[C] Consentify

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

PackagePurposeVersion
@consentify/coreHeadless consent state, cookie storage, policy versioning, typed events, GCM v22.3.x
@consentify/reactReact hook (useConsentify) for reactive state2.1.x
@consentify/cloudCloud adapter - posts events to Consentify dashboard1.0.x
create-consentifyInteractive CLI scaffolder0.1.x

Quick Start — CLI

The fastest way to add Consentify to an existing project:

npx create-consentify@latest

The 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 TagSDK (npm)Shadcn Registry
Best forAny website, no-codeReact/Next.js developersFull UI ownership
SetupOne <script> tagnpm install + confignpx shadcn add
CustomizationData attributes + dashboardFull programmatic controlEdit source code directly
Cloud AnalyticsBuilt-inOptional via @consentify/cloudPre-configured
UIAuto-rendered bannerBuild your own or use @consentify/reactPre-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

On this page