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

@phygitallabs/phygital-consent

v1.0.24

Published

Consent API, hooks, provider, and UI for the Phygital Consent Service (NCS).

Readme

@phygitallabs/phygital-consent

Consent API, hooks, provider, and UI for the Phygital Consent Service (NCS).

Main provider (recommended)

Use PhygitalConsentProvider as the single entry for consumer apps. It wraps ConsentServiceProvider and exposes hasConsentPreference + refreshConsentPreference so you can show/hide the cookie banner based on whether the user has already chosen a preference (stored in the phygital_cookie_consent cookie).

import {
  PhygitalConsentProvider,
  usePhygitalConsent,
  CookieConsentBanner,
} from "@phygitallabs/phygital-consent";

function AppWithBanner() {
  const { hasConsentPreference, refreshConsentPreference } = usePhygitalConsent();
  const deviceId = "…"; // Consumer supplies (e.g. hashed device id).

  return (
    <>
      <YourApp />
      {!hasConsentPreference && (
        <CookieConsentBanner deviceId={deviceId} onSubmitted={refreshConsentPreference} />
      )}
    </>
  );
}

// Root layout
<PhygitalConsentProvider baseURL="https://your-consent-api.example.com">
  <AppWithBanner />
</PhygitalConsentProvider>;

On Accept/Reject, the banner calls the consent API, then stores the selection in the browser cookie phygital_cookie_consent (hashed device id + selected_preferences), then calls onSubmitted so the provider refreshes and hides the banner.

Analytics (GA) consent

GA is allowed only when the user has submitted cookie preference and analytics is in selected_preferences. Use isAnalyticsAllowed() (helper) or useIsAnalyticsAllowed() (hook) or usePhygitalConsent().isAnalyticsAllowed (context). Before the GA script runs (or as the first thing in app), set gtag consent default to denied: gtag('consent', 'default', { analytics_storage: 'denied', ad_storage: 'denied' }). When isAnalyticsAllowed becomes true, call gtag('consent', 'update', { analytics_storage: 'granted' }). The consuming app owns all gtag calls; this package does not depend on window or gtag.

Using GTM (Google Tag Manager): Add a script in your HTML before the GTM container script (gtm.js) that initializes dataLayer and sets consent default to denied (see tapquest-core getGtmConsentDefaultSnippet() / GTM_CONSENT_DEFAULT_HTML). Then GtagConsentSync will push the consent update when the user accepts analytics.

Cookie consent banner

One-page cookie banner with three preferences: essential, analytics, advertising. Reject sends only essential; Accept sends all three. Use inside PhygitalConsentProvider and pass onSubmitted={refreshConsentPreference} so the banner hides after submit. The consumer app must supply deviceId (and hash it before the API if required).

Styles (Tailwind v4)

This package ships its own Tailwind v4 styles with the consent: prefix so they are not overridden by the consumer app’s Tailwind config.

  1. Import the built CSS once in your app (e.g. in your root layout or _app):

    import "@phygitallabs/phygital-consent/styles";
  2. Use prefixed utilities in any component (from this package or your app) that should use these styles:

    <div className="consent:flex consent:gap-4 consent:p-4 consent:rounded-lg">...</div>

The built CSS is generated at publish time and is not processed by the consumer’s Tailwind, so the package’s styles stay consistent regardless of the app’s theme or config.