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

@sonardigital/cookie

v1.0.0

Published

Lightweight cookie storage for Frontend apps. Save, get, update, remove.

Downloads

1

Readme

@sonardigital/cookie

A lightweight, type-safe cookie management utility for frontend applications. Built on top of the popular js-cookie library, this package provides a clean and simple API for handling browser cookies with TypeScript support.

Features

  • 🍪 Simple API - Clean and intuitive methods for cookie operations
  • 🔒 Type-safe - Full TypeScript support with proper type definitions
  • Lightweight - Minimal bundle size with zero dependencies beyond js-cookie
  • 🛡️ Secure - Built-in support for secure cookie attributes
  • 🌐 Cross-browser - Works across all modern browsers

Installation

Install the package using your preferred package manager:

npm install @sonardigital/cookie
yarn add @sonardigital/cookie
pnpm add @sonardigital/cookie

Usage

Basic Usage

import { cookies } from '@sonardigital/cookie';

// Set a cookie
cookies.set('username', 'john_doe');

// Get a cookie
const username = cookies.get('username'); // 'john_doe'

// Check if a cookie exists
const hasCookie = cookies.exists('username'); // true

// Remove a cookie
cookies.remove('username');

// Get all cookies
const allCookies = cookies.getAll(); // { username: 'john_doe', theme: 'dark' }

Advanced Usage with Options

import { cookies } from '@sonardigital/cookie';

// Set cookie with options
cookies.set('session_token', 'abc123', {
  expires: 7, // expires in 7 days
  secure: true, // only send over HTTPS
  sameSite: 'strict', // CSRF protection
  path: '/', // available across the entire site
  domain: '.example.com' // share across subdomains
});

// Remove cookie with specific options
cookies.remove('session_token', {
  path: '/',
  domain: '.example.com'
});

API Reference

cookies.set(name, value, options?)

Sets a cookie with the given name and value.

Parameters:

  • name (string): The cookie name
  • value (string): The cookie value
  • options (CookieAttributes, optional): Cookie configuration options

Options:

  • expires (number | Date): Expiration date or days until expiration
  • path (string): Cookie path (default: '/')
  • domain (string): Cookie domain
  • secure (boolean): Only send over HTTPS
  • sameSite ('strict' | 'lax' | 'none'): SameSite attribute for CSRF protection

cookies.get(name)

Retrieves a cookie by name.

Parameters:

  • name (string): The cookie name

Returns:

  • string | undefined: The cookie value or undefined if not found

cookies.exists(name)

Checks if a cookie exists.

Parameters:

  • name (string): The cookie name

Returns:

  • boolean: True if the cookie exists, false otherwise

cookies.remove(name, options?)

Removes a cookie.

Parameters:

  • name (string): The cookie name to remove
  • options (CookieAttributes, optional): Must match the options used when setting the cookie

cookies.getAll()

Retrieves all cookies as an object.

Returns:

  • Record<string, string>: Object with cookie names as keys and values as values

TypeScript Support

This package is built with TypeScript and includes comprehensive type definitions:

import { cookies, CookieType } from '@sonardigital/cookie';

// Type the cookies utility
const cookieManager: CookieType = cookies;

// Type-safe cookie operations
interface UserPreferences {
  theme: 'light' | 'dark';
  language: string;
}

const preferences: UserPreferences = {
  theme: cookies.get('theme') as 'light' | 'dark' || 'light',
  language: cookies.get('language') || 'en'
};

Development

Prerequisites

  • Node.js 16+
  • TypeScript 5.0+

Setup

# Install dependencies
npm install

# Run linting
npm run lint

# Format code
npm run format

# Run pre-commit hooks
npm run precommit

Scripts

  • npm run lint - Run ESLint
  • npm run format - Format code with Prettier
  • npm run precommit - Run pre-commit hooks (lint + format)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

ISC

Dependencies