Skip to content

Installation

sh npm install @uabcodus/consent

The library has two entry points:

Import Description
@uabcodus/consent/core Framework-agnostic core. Works in any JavaScript or TypeScript environment — no framework required.
@uabcodus/consent/react React bindings. react is an optional peer dependency (^18.0.0 or ^19.0.0).

There is no default root export — always import from one of these subpaths.

  • ESM only. Your project needs "type": "module" in package.json, or a bundler that handles ESM (Vite, Next.js, etc.).
  • TypeScript is fully supported but not required — all the examples work in plain JavaScript too.
  • React (^18.0.0 or ^19.0.0) is only needed if you use @uabcodus/consent/react.

Types are included and everything is inferred from your config — no extra type annotations needed.

import { createConsent } from "@uabcodus/consent/core";
const consent = createConsent({
categories: {
analytics: {},
marketing: {}
} as const
});
// consent.accept() is typed: "analytics" | "marketing" | "all" | "necessary"
consent.accept("analytics");

as const is the recommended pattern — it ensures TypeScript infers your category names as literal string unions, giving you autocomplete and type-safety on every call.

Ready to write some code? Head to the Quick Start →