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

@54ruum/cookies

v1.0.0

Published

Cookie utilities for 54ruum.com subdomains

Readme

@54ruum/cookies

Cookie utilities for 54ruum.com and its subdomains. This package provides cross-subdomain cookie management with a hardcoded domain for security.

Features

  • Cross-subdomain cookies - Works on 54ruum.com, app.54ruum.com, shop.54ruum.com, etc.
  • Hardcoded domain - Cannot be misused on other domains
  • Visitor tracking - Persistent visitor IDs across subdomains
  • Consent management - GDPR-compliant consent preferences
  • SSR support - Works in both client and server environments
  • TypeScript - Full type definitions included

Installation

npm install @54ruum/cookies
# or
pnpm add @54ruum/cookies
# or
yarn add @54ruum/cookies

Quick Start

Client-Side Usage

import { 
  setConsent, 
  getOrCreateVisitorId, 
  hasConsented 
} from "@54ruum/cookies";

// Handle cookie consent popup
function handleAcceptCookies() {
  setConsent({ 
    analytics: true, 
    preferences: true, 
    marketing: false 
  });
  
  const visitorId = getOrCreateVisitorId();
  console.log("Visitor ID:", visitorId);
}

// Check if consent popup should be shown
if (!hasConsented()) {
  showConsentPopup();
}

Server-Side Usage (SSR)

import { parseCookies, getVisitorId, getConsentFromCookies } from "@54ruum/cookies";

// React Router loader
export async function loader({ request }) {
  const cookies = parseCookies(request.headers.get("Cookie") || "");
  const visitorId = getVisitorId(cookies);
  const consent = getConsentFromCookies(cookies);
  
  return { 
    visitorId,
    shouldLoadAnalytics: consent?.analytics ?? false 
  };
}

API Reference

Visitor Tracking

getOrCreateVisitorId(): string

Get existing visitor ID or create a new one (client-side only).

const visitorId = getOrCreateVisitorId();

getVisitorId(cookies: ParsedCookies): string | null

Get visitor ID from parsed cookies (for server-side use).

const cookies = parseCookies(request.headers.get("Cookie") || "");
const visitorId = getVisitorId(cookies);

generateVisitorId(): string

Generate a new UUID-style visitor ID.

const newId = generateVisitorId();

Consent Management

setConsent(preferences: ConsentPreferences): void

Store user's cookie consent preferences.

setConsent({
  analytics: true,
  preferences: true,
  marketing: false,
});

getConsent(): ConsentPreferences | null

Get current consent preferences (client-side).

const consent = getConsent();
if (consent?.analytics) {
  initAnalytics();
}

hasConsented(): boolean

Check if user has given any consent.

if (!hasConsented()) {
  showConsentPopup();
}

getConsentFromCookies(cookies: ParsedCookies): ConsentPreferences | null

Get consent from parsed cookies (server-side).

const consent = getConsentFromCookies(parseCookies(cookieHeader));

Core Cookie Operations

setCookie(name: string, value: string, options?: CookieOptions): void

Set a cookie (automatically uses .54ruum.com domain).

setCookie("my_cookie", "value", { maxAge: 3600 });

getCookie(name: string): string | null

Get a cookie value by name.

const value = getCookie("my_cookie");

deleteCookie(name: string): void

Delete a cookie.

deleteCookie("my_cookie");

parseCookies(cookieString: string): ParsedCookies

Parse a cookie string into an object (for SSR).

const cookies = parseCookies(request.headers.get("Cookie") || "");

Constants

import { COOKIE_NAMES, COOKIE_MAX_AGE, COOKIE_DOMAIN } from "@54ruum/cookies";

COOKIE_DOMAIN      // ".54ruum.com"
COOKIE_NAMES.VISITOR_ID   // "ruum_vid"
COOKIE_NAMES.CONSENT      // "ruum_consent"
COOKIE_NAMES.PREFERENCES  // "ruum_prefs"
COOKIE_NAMES.SESSION      // "ruum_session"

COOKIE_MAX_AGE.VISITOR     // 2 years (in seconds)
COOKIE_MAX_AGE.CONSENT     // 1 year
COOKIE_MAX_AGE.PREFERENCES // 1 year
COOKIE_MAX_AGE.SESSION     // 7 days

Types

interface ConsentPreferences {
  analytics: boolean;
  preferences: boolean;
  marketing: boolean;
}

interface CookieOptions {
  maxAge?: number;
  path?: string;
  secure?: boolean;
  sameSite?: "strict" | "lax" | "none";
  httpOnly?: boolean;
}

type ParsedCookies = Record<string, string>;

Security

This package is designed to work exclusively on 54ruum.com and its subdomains. The domain is hardcoded and cannot be changed or overridden, preventing misuse on other domains.

Local Development

The package automatically detects localhost environments and skips the domain restriction, allowing cookies to work during local development:

  • localhost
  • 127.0.0.1
  • 192.168.* (local network)
  • *.local (mDNS)

In production on any *.54ruum.com domain, cookies are automatically shared across all subdomains.

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

# Run tests
npm test

Local Development

For testing with other 54ruum projects before publishing:

# In this repo
npm link

# In consumer repo
npm link @54ruum/cookies

License

MIT