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

license-lib

v1.0.7

Published

Simple, secure licensing library for Node.js, React, and Next.js.

Readme

License Key Library

A simple, secure, and flexible licensing library built for Node.js, React, Next.js, and general JavaScript applications.


🚀 Quick Start

Installation

npm install license-lib

Environment Setup Create a .env file at the root with your database, backend url and JWT configuration:

DB_HOST=localhost
DB_NAME=license_db
DB_USER_ADMIN=license_admin
DB_PASS_ADMIN=secure_admin_password
DB_USER_READER=license_reader
DB_PASS_READER=secure_reader_password
JWT_SECRET=your_jwt_secret
VITE_LICENSE_API_URL=https://your.backend.url.com/api #or http://localhost:3000

⚙️ Database Setup

Use the provided SQL script to set up your database:

CREATE DATABASE license_db;

USE license_db;

CREATE TABLE licenses (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id VARCHAR(255) NOT NULL,
  hashed_key VARCHAR(255) NOT NULL,
  license_type ENUM('one-time', 'subscription', 'trial') DEFAULT 'one-time',
  tier VARCHAR(50) DEFAULT 'basic',
  valid_until DATETIME DEFAULT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

CREATE USER 'license_reader'@'%' IDENTIFIED BY 'secure_reader_password';
GRANT SELECT ON license_db.* TO 'license_reader'@'%';

CREATE USER 'license_admin'@'%' IDENTIFIED BY 'secure_admin_password';
GRANT SELECT, INSERT, UPDATE ON license_db.* TO 'license_admin'@'%';

FLUSH PRIVILEGES;

📦 API Endpoints

Generate License

POST /generate-license

Body:

{
  "userId": "user123",
  "licenseType": "subscription",
  "tier": "pro",
  "validUntil": "2024-12-31"
}

Response:

{
  "licenseKey": "generated.jwt.token"
}

Validate License

POST /validate-license

Body:

{
  "userId": "user123",
  "licenseKey": "generated.jwt.token"
}

Response:

{
  "valid": true
}

🎯 Client Integration Import functions directly from the client module:

import { activateLicense, generateFingerprint } from './client';

// Validate license
const valid = await activateLicense(userId, licenseKey);

// Device fingerprinting
const fingerprint = generateFingerprint();

⚛️ React Integration Use the provided React hook and provider:

import { LicenseProvider } from './react/LicenseProvider';
import useLicense from './react/useLicense';

const App = () => (
  <LicenseProvider userId="user123" licenseKey="jwt.token">
    <YourApp />
  </LicenseProvider>
);

const YourApp = () => {
  const { isLicensed } = useLicense();
  return <div>{isLicensed ? 'Licensed!' : 'Not Licensed!'}</div>;
};

▲ Next.js Integration Wrap your component easily:

import withLicense from './nextjs/withLicense';

const Page = ({ isLicensed }) => (
  <div>{isLicensed ? 'Licensed!' : 'Not Licensed!'}</div>
);

export default withLicense(Page, { userId: 'user123', licenseKey: 'jwt.token' });