npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@palmetto/cookie-consent

v0.1.0

Published

Shared CookieYes consent integration for Palmetto frontends and backends. One versioned package so each repo stops re-implementing the same consent glue.

Downloads

71

Readme

@palmetto/cookie-consent

Shared CookieYes consent integration for Palmetto frontends and backends. One versioned package so each repo stops re-implementing the same consent glue.

The cookie banner itself is rendered by CookieYes's own CDN script — this package ships the logic around it (reading consent, subscribing to changes, gating Segment, parsing the consent cookie server-side), not any UI.

Installation

yarn add @palmetto/cookie-consent

Peer dependencies are installed only for the subpaths you use:

  • ./reactreact (>=18)
  • ./segment@segment/analytics-consent-tools (>=1)
  • . and ./server → no peers

Entry points

| Import | Use in | Contents | | ---------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | @palmetto/cookie-consent | any browser code | getCkyConsent, onCkyConsentUpdate, DEFAULT_CONSENT_CATEGORIES, activeLawToConsentModel, injectCookieYesScript, the shared types, and the ambient window.getCkyConsent typing | | @palmetto/cookie-consent/react | React apps | useCkyConsent(), <CookieConsentProvider> | | @palmetto/cookie-consent/segment | apps loading Segment | withCookieYes(), CookieYesSettings | | @palmetto/cookie-consent/server | Node/Nest | parseConsentCookie(), KNOWN_CONSENT_CATEGORIES, DEFAULT_CONSENT | | @palmetto/cookie-consent/testing | tests / local dev | setMockConsent(), clearMockConsent() — simulate consent without CookieYes (needs a DOM) |

The subpaths keep react out of backends and @segment/* out of consumers that gate their own analytics — importing /server never pulls a browser or React module into the require graph.

Getting started

Loading the CookieYes script

The zone ID and feature gate stay per-app env — this package does not ship a ready-made loader component.

Vite (client-only):

import { injectCookieYesScript } from "@palmetto/cookie-consent";

useEffect(() => {
  injectCookieYesScript(import.meta.env.VITE_COOKIEYES_ZONE_ID);
}, []);

Next.js: keep next/script with strategy="beforeInteractive" for SSR ordering — do not use injectCookieYesScript.

Reading consent in React

import { useCkyConsent } from "@palmetto/cookie-consent/react";

function Analytics() {
  const { categories } = useCkyConsent();
  if (!categories.analytics) return null;
  // ...
}

Gating Segment

import { withCookieYes } from "@palmetto/cookie-consent/segment";

export const analytics = withCookieYes(new AnalyticsBrowser());

Server (Nest middleware)

import { parseConsentCookie } from "@palmetto/cookie-consent/server";

const consent = parseConsentCookie(req.cookies["cookieyes-consent"]);

Local development & testing

CookieYes does not load on localhost — its zones are domain-restricted, so no banner appears and window.getCkyConsent is never installed. You have two ways to work around this:

  1. Mock consent (unit tests, local UI work) — drive consent-gated code directly, no CookieYes required:

    import {
      setMockConsent,
      clearMockConsent,
    } from "@palmetto/cookie-consent/testing";
    
    // simulate a visitor who accepted analytics
    setMockConsent({
      categories: { analytics: true },
      isUserActionCompleted: true,
    });
    // ...assert your gated behavior...
    clearMockConsent(); // in teardown

    Under the hood this installs window.getCkyConsent and dispatches the cookieyes_consent_update event — the same thing the real CDN script does. Needs a DOM (jsdom in tests, or a real browser console for manual poking).

  2. Real banner against localhost — register a staging URL (or a tunnel URL from ngrok/cloudflared) as the site URL in a CookieYes zone, then run the app behind that URL. CookieYes lets you switch the zone's URL later, so you can start with staging and repoint to production.

Notes for consumers

  • The data-cookieyes="..." pixel category slugs stay per-app config — they must match the slugs configured in each app's CookieYes dashboard zone.
  • activeLaw values and the exact CkyConsent shape mirror what CookieYes emits; treat this package's types as the single source of truth across repos.