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

tinyconsent

v1.0.1

Published

Lightweight cookie consent banner loader. One-line GDPR/CCPA compliant cookie banner integration for any website.

Readme

tinyconsent

npm version License: MIT TypeScript

The easiest way to add a GDPR/CCPA compliant cookie banner to any website.

A lightweight loader for TinyConsent cookie banners. One function call to add a GDPR/CCPA-style cookie banner to your site.

Why TinyConsent?

  • 🚀 One-line integration - Add a cookie banner in seconds
  • 📦 Tiny footprint - Under 1KB, loads the actual banner async
  • Cookie consent handling - Loads your TinyConsent banner and lets you wire consent into your tracking scripts
  • 🔧 Designed for Google Consent Mode v2 - Works with GA4-style implementations
  • 🎨 Customizable - Configure via dashboard, no code changes
  • 📱 Works everywhere - Vanilla JS, React, Vue, Next.js, and more

Get your script ID: tinyconsent.com/cookie-banner-generator

Installation

npm install tinyconsent
yarn add tinyconsent
pnpm add tinyconsent

Quick Start

JavaScript / TypeScript

import { loadTinyConsent } from 'tinyconsent';

// Load your cookie banner
loadTinyConsent('your-script-id');

That's it! Your cookie consent banner will appear automatically.

React Hook

import { useTinyConsent } from 'tinyconsent';

function App() {
  const { isLoading, isLoaded, error } = useTinyConsent('your-script-id');
  
  return <div>My App</div>;
}

With Options

import { loadTinyConsent } from 'tinyconsent';

loadTinyConsent('your-script-id', {
  async: true,
  onLoad: () => console.log('Cookie banner ready!'),
  onError: (err) => console.error('Failed to load:', err)
});

API Reference

loadTinyConsent(scriptId, options?)

Loads the TinyConsent cookie consent banner script.

| Parameter | Type | Description | |-----------|------|-------------| | scriptId | string | Your unique script ID from tinyconsent.com | | options.async | boolean | Load asynchronously (default: true) | | options.defer | boolean | Defer execution (default: false) | | options.onLoad | () => void | Callback when loaded | | options.onError | (error: Error) => void | Callback on error |

Returns: Promise<void>

useTinyConsent(scriptId, options?) (React)

React hook for loading the cookie banner.

const { isLoading, isLoaded, error } = useTinyConsent('your-script-id');

Returns: { isLoading: boolean, isLoaded: boolean, error: Error | null }

getTinyConsentScriptUrl(scriptId)

Get the full script URL for manual insertion.

const url = getTinyConsentScriptUrl('your-script-id');
// 'https://scripts.tinyconsent.com/api/scripts/your-script-id'

isTinyConsentLoaded(scriptId)

Check if the script is already loaded.

if (!isTinyConsentLoaded('your-script-id')) {
  loadTinyConsent('your-script-id');
}

Framework Examples

Next.js (App Router)

// app/layout.tsx
'use client';

import { useEffect } from 'react';
import { loadTinyConsent } from 'tinyconsent';

export default function RootLayout({ children }) {
  useEffect(() => {
    loadTinyConsent('your-script-id');
  }, []);

  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

Vue.js

<script setup>
import { onMounted } from 'vue';
import { loadTinyConsent } from 'tinyconsent';

onMounted(() => {
  loadTinyConsent('your-script-id');
});
</script>

Vanilla JavaScript

<script type="module">
  import { loadTinyConsent } from 'https://esm.sh/tinyconsent';
  loadTinyConsent('your-script-id');
</script>

What is a Cookie Banner?

A cookie banner (also called a cookie consent banner or cookie notice) is a UI element that:

  1. Informs users about cookies and tracking on your website
  2. Collects consent before setting non-essential cookies
  3. Provides control for users to accept, reject, or customize preferences

Learn more: What is a Cookie Banner?

Cookie Banners vs. Full Compliance

What a Cookie Banner Does

A cookie banner handles the consent collection part of privacy compliance:

  • Displays a notice about cookies and tracking
  • Collects user consent preferences
  • Blocks non-essential scripts until consent is given
  • Stores and respects consent choices

What Full Compliance Requires

Cookie consent is just one part of privacy law compliance. Full compliance also includes:

  • Privacy Policy - Document explaining your data practices
  • Data Processing Records - Internal documentation of data handling
  • User Rights Handling - Processes for data access/deletion requests
  • Legal Basis Documentation - Justification for each type of data processing

TinyConsent helps with cookie consent. For your privacy policy, use: tinyconsent.com/privacy-policy-generator

GDPR Cookie Consent Requirements

The GDPR requires specific handling for cookies:

  • Get consent BEFORE setting non-essential cookies
  • Users must be able to reject cookies easily
  • Consent must be freely given, specific, and informed
  • Must provide granular consent options (analytics, marketing, etc.)
  • No pre-ticked boxes allowed

Learn more: GDPR Cookie Requirements

CCPA Requirements

The CCPA (California Consumer Privacy Act) requires:

  • Disclose what personal information you collect
  • Provide "Do Not Sell My Personal Information" option
  • Cannot discriminate against users who opt out

Learn more: CCPA Cookie Requirements

FAQ

How do I get a script ID?

  1. Visit tinyconsent.com/cookie-banner-generator
  2. Enter your email
  3. Copy your personalized script ID

Does this block tracking scripts?

TinyConsent is built to work with tracking tools like Google Analytics and Facebook Pixel. You can configure your scripts to respect the consent state provided by TinyConsent.

Does it work with Google Analytics 4?

Yes. TinyConsent is designed to work with Google Consent Mode v2 and GA4-style implementations.

How big is the banner script?

The initial loader is under 5KB gzipped. It loads asynchronously and won't affect your page speed.

Can I customize the banner?

Yes! All customization (colors, text, position) is done in your TinyConsent Dashboard. No code changes needed.

Do I need a privacy policy too?

Yes, GDPR requires a privacy policy. Generate one for free: tinyconsent.com/privacy-policy-generator

Troubleshooting

Banner not appearing

  1. Check your script ID is correct
  2. Ensure the script isn't being blocked by ad blockers
  3. Clear localStorage and test in incognito mode
  4. Check browser console for errors

Scripts still running before consent

Make sure loadTinyConsent() is called before your tracking scripts load.

React hydration warnings

Use the useTinyConsent hook or call loadTinyConsent in a useEffect.

TypeScript

Full TypeScript support included:

import { 
  loadTinyConsent, 
  useTinyConsent,
  getTinyConsentScriptUrl,
  isTinyConsentLoaded,
  LoadTinyConsentOptions,
  UseTinyConsentResult 
} from 'tinyconsent';

Related Packages

Resources

License

MIT © TinyConsent


Keywords: cookie banner, cookie consent, GDPR, CCPA, cookie banner generator, cookie consent script, GDPR cookie banner, one line cookie banner, lightweight cookie consent, cookie banner npm, cookie banner react, privacy, consent management