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

better-auth-consent

v0.0.1

Published

Lightweight consent management plugin for Better Auth - Simple cookie and privacy consent

Readme

better-auth-consent

Lightweight consent management plugin for Better Auth - Simple cookie and privacy consent without the complexity of full compliance

Status

⚠️ Work in Progress - This package is under active development and not yet ready for production use.

When to Use This Package

  • Use better-auth-consent if you need:
    • Simple cookie consent banners
    • Basic privacy preferences
    • Lightweight consent tracking
    • Quick setup without compliance overhead
  • Use better-auth-compliance instead if you need:
    • Full GDPR/CCPA compliance
    • Data rights management (deletion, portability)
    • Age verification (COPPA)
    • Regional data residency
    • Audit trails and legal documentation

Features (Planned)

  • 🍪 Cookie Consent - Simple, customizable cookie consent banners
  • 📊 Consent Categories - Necessary, Analytics, Marketing, Functional
  • 🎨 UI Components - Ready-to-use consent banner components
  • 💾 Preference Center - User-friendly privacy preference management
  • 🔄 Consent Sync - Sync preferences across devices
  • 📝 Consent Records - Track when and what users consented to
  • 🌍 Multi-language - Internationalization support
  • Performance - Lightweight with minimal overhead
  • 🎯 Granular Control - Service-level consent (Google Analytics, Facebook, etc.)
  • 🔔 Update Notifications - Notify users of privacy policy changes

Installation

npm install better-auth-consent

Usage

import { betterAuth } from "better-auth";
import { consent } from "better-auth-consent";

const auth = betterAuth({
  plugins: [
    consent({
      // Cookie categories
      categories: {
        necessary: {
          label: "Necessary",
          description: "Essential for the website to function",
          required: true, // Cannot be disabled
        },
        analytics: {
          label: "Analytics",
          description: "Help us understand how you use our site",
          default: false,
          services: ["google-analytics", "mixpanel"],
        },
        marketing: {
          label: "Marketing",
          description: "Personalized ads and content",
          default: false,
          services: ["google-ads", "facebook-pixel"],
        },
        functional: {
          label: "Functional",
          description: "Enhanced functionality and personalization",
          default: true,
          services: ["intercom", "youtube"],
        },
      },
      
      // Banner configuration
      banner: {
        position: "bottom", // bottom, top, center
        theme: "light", // light, dark, auto
        logo: "/logo.png",
        privacyPolicy: "/privacy",
        cookiePolicy: "/cookies",
        rejectButton: true,
        customizeButton: true,
      },
      
      // Behavior
      behavior: {
        acceptOnScroll: false,
        acceptOnNavigate: false,
        reloadOnChange: false,
        cookieExpiry: 365, // days
        regionDetection: true, // Auto-detect EU/California
      },
      
      // Callbacks
      onAccept: async (categories) => {
        // Initialize accepted services
        if (categories.analytics) {
          // Initialize Google Analytics
        }
      },
      onReject: async () => {
        // Clean up any already set cookies
      },
      onChange: async (categories) => {
        // Handle preference changes
      },
    }),
  ],
});

Client Usage

import { createAuthClient } from "better-auth/client";
import { consentClient } from "better-auth-consent/client";

const authClient = createAuthClient({
  plugins: [consentClient()]
});

// Check consent status
const status = await authClient.consent.getStatus();
console.log(status.categories); // { necessary: true, analytics: false, ... }

// Update preferences
await authClient.consent.updatePreferences({
  analytics: true,
  marketing: false,
  functional: true,
});

// Show preference center
authClient.consent.showPreferences();

// Revoke all consent
await authClient.consent.revokeAll();

// Check if specific service is allowed
const canUseGA = authClient.consent.isServiceAllowed("google-analytics");

UI Components (React Example)

import { ConsentBanner, PreferenceCenter } from "better-auth-consent/react";

function App() {
  return (
    <>
      {/* Automatic consent banner */}
      <ConsentBanner />
      
      {/* Preference center for settings page */}
      <PreferenceCenter />
    </>
  );
}

Simple Integration

// Conditional script loading based on consent
if (authClient.consent.isServiceAllowed("google-analytics")) {
  // Load Google Analytics
  gtag('config', 'GA_MEASUREMENT_ID');
}

// Listen for consent changes
authClient.consent.on("change", (categories) => {
  if (categories.marketing) {
    // Enable marketing tools
  } else {
    // Disable marketing tools
  }
});

Comparison with better-auth-compliance

| Feature | better-auth-consent | better-auth-compliance | |---------|-------------------|----------------------| | Cookie consent | ✅ Simple | ✅ Advanced | | Preference management | ✅ | ✅ | | GDPR compliance | ⚠️ Basic | ✅ Full | | CCPA compliance | ⚠️ Basic | ✅ Full | | Data rights | ❌ | ✅ | | Age verification | ❌ | ✅ | | Audit trails | ⚠️ Basic | ✅ Advanced | | Bundle size | ~10KB | ~50KB | | Setup complexity | Simple | Moderate |

License

MIT