[C] Consentify

create-consentify CLI

Interactive scaffolder that wires @consentify/core into your project in ~30 seconds.

create-consentify is the recommended starting point for any project that uses a bundler. It asks a few questions, installs the right packages, and writes framework-specific glue code.

Usage

npx create-consentify@latest
# or
pnpm create consentify
# or
bunx create-consentify

What It Does

  1. Detects (or asks about) your framework
  2. Prompts for consent categories, mode (opt-in / opt-out), and optional Google Consent Mode v2 wiring
  3. Optionally connects to the Consentify dashboard for analytics (site ID + API key)
  4. Installs @consentify/core (+ @consentify/react / @consentify/cloud when relevant)
  5. Writes a lib/consent.ts and a provider component for your framework
  6. Prints the exact snippet to paste into your root layout / entry file

The CLI never modifies your existing layout.tsx, _app.tsx, main.tsx, or root.tsx - those edits are shown as instructions for you to apply.

Supported Frameworks

  • Next.js (App Router)
  • Next.js (Pages Router)
  • Vite + React
  • Remix
  • Astro
  • Vanilla JS / HTML

Non-Interactive (CI)

npx create-consentify@latest \
  --framework nextjs-app \
  --categories analytics,marketing \
  --mode opt-in \
  --gcm \
  --site-id site_xxx \
  --api-key sk_xxx \
  --pm pnpm \
  --yes

All flags are optional; any missing flag triggers a prompt unless --yes is set and the combination is complete.

FlagValues
--frameworknextjs-app, nextjs-pages, vite-react, remix, astro, vanilla
--categoriesComma-separated (e.g. analytics,marketing). necessary is implicit.
--modeopt-in (GDPR, default) | opt-out (CCPA)
--gcmEnable Google Consent Mode v2 wiring
--site-idConsentify dashboard Site ID (implies SaaS mode)
--api-keyDashboard API key (optional)
--pmpnpm | npm | yarn | bun
--cwdTarget project directory (default: process.cwd())
--yesSkip confirmation prompts

Output Structure

For a Next.js App Router project with analytics + marketing categories:

src/
├── lib/
│   └── consent.ts          # createConsentify() + optional enableCloud()
├── components/
│   └── consent-provider.tsx # Client component with useConsentify()
└── .env.local              # NEXT_PUBLIC_CONSENTIFY_SITE_ID (if SaaS connected)

After scaffolding, import the provider into your root layout as instructed in the CLI output.

On this page