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

ngx-cookie-ssr

v2.0.1

Published

Ng Cookie Service is a simple cookie service for Angular applications. This is heavily inspired by [ngx-cookie-service](https://github.com/stevermeister/ngx-cookie-service). But only intended to be used with Angular 19 and onwards.

Readme

Ng Cookie Service

Ng Cookie Service is a simple cookie service for Angular applications. This is heavily inspired by ngx-cookie-service. But only intended to be used with Angular 19 and onwards.

Usage

import { CookieService } from "ngx-cookie-ssr";
import { Component, inject } from "@angular/core";

@Component({
  selector: "my-component",
  template: `<h1>Hello World</h1>`,
  providers: [CookieService],
})
export class HelloComponent {
  private cookieService = inject(CookieService);
  private platformId = inject(PLATFORM_ID);

  constructor() {
    if (isPlatformServer(this.platformId)) {
      this.cookieService.set("token_server", "server");
    } else {
      this.cookieService.set("token_client", "client");
    }
  }
}

Server Side Rendering

This library out of the box supports server side rendering (SSR). However, to get access to the cookie, your appilcation need to be in hybrid render mode (from angular 19).

export const serverRoutes: ServerRoute[] = [
  {
    path: "**",
    renderMode: RenderMode.Server,
  },
];

See Accessing request and response via DI for more information.

API

check(name: string): boolean;

const cookieExists: boolean = cookieService.check("test");

Checks if a cookie with the givenname can be accessed or found.

get(name: string): string;

const value: string = cookieService.get("test");

Gets the value of the cookie with the specified name.

getAll(): {};

const allCookies: {} = cookieService.getAll();

Returns a map of key-value pairs for cookies that can be accessed.

set(name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'Strict' | 'None'): void;

set(name: string, value: string, options?: { expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict'}): void;

cookieService.set("test", "Hello World");
cookieService.set("test", "Hello World", { expires: 2, sameSite: "Lax" });

Sets a cookie with the specified name and value. It is good practice to specify a path. If you are unsure about the path value, use '/'. If no path or domain is explicitly defined, the current location is assumed. sameSite defaults to Lax.

Important: For security reasons, it is not possible to define cookies for other domains. Browsers do not allow this. Read this and this StackOverflow answer for a more in-depth explanation.

Important: Browsers do not accept cookies flagged sameSite = 'None' if secure flag isn't set as well. CookieService will override the secure flag to true if sameSite='None'.

delete(name: string, path?: string, domain?: string, secure?: boolean, sameSite: 'Lax' | 'None' | 'Strict' = 'Lax'): void;

cookieService.delete("test");

Deletes a cookie with the specified name. It is best practice to always define a path. If you are unsure about the path value, use '/'.

Important: For security reasons, it is not possible to delete cookies for other domains. Browsers do not allow this. Read this and this StackOverflow answer for a more in-depth explanation.

deleteAll(path?: string, domain?: string, secure?: boolean, sameSite: 'Lax' | 'None' | 'Strict' = 'Lax'): void;

cookieService.deleteAll();

Deletes all cookies that can currently be accessed. It is best practice to always define a path. If you are unsure about the path value, use '/'.