Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Angular
  3. ngx-cookie-service

ngx-cookie-service

MITTypeScriptv22.0.0

A lightweight Angular service for reading, setting, and deleting browser cookies with SSR support.

Visit WebsiteGitHubGitHub
561 stars90 forks0 contributors

What is ngx-cookie-service?

NGX Cookie Service is an Angular library that provides a service for managing browser cookies within Angular applications. It solves the problem of handling cookies in a type-safe, Angular-native way, offering methods to read, set, and delete cookies with support for modern attributes like sameSite and secure flags. It is designed to work with Angular 4.2+ up to the latest versions, including support for server-side rendering.

Target Audience

Angular developers who need to manage browser cookies for features like authentication tokens, user preferences, or session data in their applications, especially those using or considering server-side rendering.

Value Proposition

Developers choose NGX Cookie Service for its minimal bundle size, seamless Angular integration, and dedicated SSR support. It replaces manual `document.cookie` manipulation or older libraries with a clean, injectable service that follows Angular's design patterns and includes comprehensive cookie attribute handling.

Overview

Angular (4.2+ ...12) service for cookies. Originally based on the ng2-cookies library.

Use Cases

Best For

  • Managing authentication tokens or session cookies in Angular apps
  • Implementing cookie-based user preferences or consent banners
  • Angular Universal or SSR projects requiring server-side cookie access
  • Applications needing type-safe cookie operations with sameSite support
  • Lightweight projects where bundle size is a critical concern
  • Migrating from ng2-cookies or similar older Angular cookie libraries

Not Ideal For

  • Applications built with other frameworks like React or Vue.js, as it's Angular-specific
  • Projects that only need simple cookie reading and prefer using native document.cookie to avoid dependencies
  • Legacy Angular applications using versions below 15.x.x, which are not supported
  • Teams looking for a unified storage solution that includes localStorage or sessionStorage alongside cookies

Pros & Cons

Pros

Minimal Bundle Size

At only 1.3 KB minified, it has negligible impact on load times, as highlighted in the README's bundle size badge.

Comprehensive Cookie API

Provides full control over cookie attributes like expires, path, domain, secure, and sameSite, covering all standard browser cookie operations.

Native Angular Integration

Designed for Angular's dependency injection, supporting both constructor injection and the inject() method, making it feel seamless in Angular apps.

Dedicated SSR Support

Offers a separate ngx-cookie-service-ssr package for server-side rendering, ensuring cookies are accessible in Angular Universal environments.

Cons

SSR Setup Overhead

Requires installing a separate package and modifying server.ts to provide REQUEST and RESPONSE objects, adding complexity compared to a single-package solution.

Limited Backward Compatibility

Only supports Angular 15.x.x and above, excluding older versions that might still be in use, as noted in the supported versions table.

Inherent Browser Constraints

Cannot set or delete cookies for other domains due to browser security, which might confuse developers expecting more flexibility, as mentioned in the API warnings.

Frequently Asked Questions

Quick Stats

Stars561
Forks90
Contributors0
Open Issues0
Last commit2 days ago
CreatedSince 2017

Tags

#cookies#authentication#angular2#ngx#browser-api#angular-universal#frontend#typescript#cookie#ng#angular#ssr#aot#state-management#angular-service#cookie-management

Built With

A
Angular
T
TypeScript

Links & Resources

Website

Included in

Angular10.0k
Auto-fetched 1 hour ago

Related Projects

cookieconsentcookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js

Stars5,568
Forks507
Last commit2 months ago
ngx-cookie-consentngx-cookie-consent

Angular multi-language module to display a cookie consent banner without other dependencies.

Stars16
Forks7
Last commit2 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub