Skip to content

Getting Started

VS Cookies ships as a small runtime plus one skin per banner, distributed as zip archives you add to your project by hand — not through a package registry. Each integration is two zips.

Download the zips from the VS GOODS store, unzip them into a vendor/ folder, and wire up the specifiers in your bundler (or an import map for plain HTML). See Installing from the zip for the full walkthrough.

  • React app → @vscookies/react + @vscookies/skin-<slug>-react.
  • Plain HTML / any stack → @vscookies/vanilla + @vscookies/skin-<slug>-vanilla.
  • Fully custom UI → @vscookies/core (add @vscookies/tokens for the CSS variables).
App.tsx
import { CookieConsentProvider } from "@vscookies/react";
import { MinimalistBanner } from "@vscookies/skin-minimalist-react";
export default function App() {
return (
<CookieConsentProvider>
<MinimalistBanner mode="light" />
</CookieConsentProvider>
);
}

Importing a skin self-registers it and injects only that skin’s CSS — no extra stylesheet import is required. You can mount several skins; they share one consent store. See the React guide for the full props reference and adding your own tags & cookies via the provider’s config prop.

import { CookieConsentProvider, useCookieConsent } from "@vscookies/react";

Use useCookieConsent to read state and trigger decisions, then render whatever markup you like. See Build your own UI.

<script type="importmap">
{
"imports": {
"@vscookies/vanilla": "./vendor/vscookies/vanilla/dist/index.js",
"@vscookies/vanilla/define": "./vendor/vscookies/vanilla/dist/define.js",
"@vscookies/vanilla/internal/react": "./vendor/vscookies/vanilla/dist/internal/react.js",
"@vscookies/vanilla/internal/headless": "./vendor/vscookies/vanilla/dist/internal/headless.js",
"@vscookies/skin-minimalist-vanilla": "./vendor/vscookies/skin-minimalist-vanilla/dist/index.js"
}
}
</script>
<script type="module">
import { defineAll } from "@vscookies/vanilla/define";
import "@vscookies/skin-minimalist-vanilla";
defineAll();
</script>
<vscookies-minimalist></vscookies-minimalist>

See the Vanilla guide for attributes and the custom-element properties. To attach your own tags/cookies, pass a config once: defineAll({ categories: { ...DEFAULT_CATEGORY_RULES, … } }) — see adding your own tags & cookies.

Both runtimes bundle @vscookies/tokens and load its global state variables for you. UI values are owned by each skin. The same contract is exported from each runtime: GLOBAL_TOKEN_MANIFEST, GLOBAL_TOKEN_NAMES, setTokenOverrides(values, { skin? }), clearTokenOverrides({ skin? }) and clearAllTokenOverrides(). Use these to build your own live token editor — see Tokens. All visual values are CSS variables (--vsc-state-* plus each skin’s prefix).

EnvironmentNotes
Client-rendered ReactDrop the provider at the app root; skins mount inside it.
SSR / RSCThe core is browser-safe (it no-ops without document). Render banners behind a client boundary/mount.
Plain HTMLUse @vscookies/vanilla with an import map and a skin zip.
  • Skins — pick a banner skin.
  • Core — the headless API.
  • React — runtime, hook, and skin props.
  • Use cases — copy-paste recipes.
  • Run pnpm storybook to try the library against a realistic fake consent config (fake tags with setsCookies, cookies, custom category) — see the Library behavior stories.