Installation
Package manager
Section titled “Package manager”sh npm install @uabcodus/consent sh pnpm add @uabcodus/consent sh yarn add @uabcodus/consent sh bun install @uabcodus/consent Package exports
Section titled “Package exports”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.
Requirements
Section titled “Requirements”- ESM only. Your project needs
"type": "module"inpackage.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.0or^19.0.0) is only needed if you use@uabcodus/consent/react.
TypeScript
Section titled “TypeScript”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.
Next steps
Section titled “Next steps”Ready to write some code? Head to the Quick Start →