u/Aboudbadra

Rebuilt a cookie-consent lib for modern Angular (standalone + signals) — would love feedback before 1.0
▲ 10 r/angular

Rebuilt a cookie-consent lib for modern Angular (standalone + signals) — would love feedback before 1.0

Most cookie-consent options I evaluated for a recent Angular project felt tied to the NgModule era, pulled in dependencies I didn't want, or hadn't seen a commit in a while. So I ended up rebuilding one from scratch for Angular v17+.

Current state — v0.6, working towards a stable v1.0:

  • Standalone components, no NgModule
  • Signal-based consent state (with RxJS bridges for the holdouts)
  • Functional setup: provideCookieConsent({ ... })
  • *ngrIfConsent="'youtube'" for conditional rendering
  • Google Consent Mode v2 adapter built in — maps your category state to gtag consent signals (the only adapter shipped today; others can plug in)
  • SSR-safe, zero runtime deps
  • Compose categories from typed cookie items each having their own toggle (GOOGLE_ANALYTICS, META_PIXEL, HOTJAR, YOUTUBE, …) via a makeCategory() helper — or hand-roll a category if you want full control.

A simple Live demo (interactive): https://ngrithms.aalbadra.workers.dev/cookie-consent

What I'm not sure about yet and would genuinely like opinions on:

  1. Storage is a cookie on the current origin. Has anyone needed cross-device / server-side persistence + an audit log of consent changes, or is that comfortably out-of-scope for a frontend library?
  2. Anything you've hit in production with other consent libs that you'd want this one to handle out of the box?

Not trying to dunk on existing libs. This is just the version I wished existed when I started.

https://preview.redd.it/is97zz5cyn1h1.png?width=2880&format=png&auto=webp&s=fabfa5917085cabcda4099350f89647e01ddf757

Repo: https://github.com/aboudbadra/ngrithms-cookie-consent

npm: https://www.npmjs.com/package/@ngrithms/cookie-consent

Happy to take harsh feedback — better now than after 1.0.

This is part of a small family of focused Angular libraries I've been building under `@ngrithms/*`. The other one currently live is `@ngrithms/idle` (signal-first user-inactivity detector with multi-tab sync) — demo at https://ngrithms.aalbadra.workers.dev/idle if anyone's curious. If you've got a "I wish there was a small Angular lib that just did X" itch, I'm taking suggestions.

reddit.com
u/Aboudbadra — 4 days ago