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

shorten-ly

v0.0.2-alpha

Published

πŸ“Œ A simple URL shortener library with Express & SQLite

Downloads

11

Readme

shorten-ly πŸš€ - A Simple URL Shortener Library

shorten-ly is a lightweight Node.js library that lets you shorten URLs, retrieve original links, and track analytics using SQLite.

✨ Features

  • βœ… Shorten long URLs into compact links
  • βœ… Retrieve the original URL from a shortened link
  • βœ… Track visit analytics for each short link
  • βœ… Use SQLite for persistence (supports both file-based and in-memory storage)
  • βœ… Customize your domain for shortened links

πŸ“¦ Installation

Install the package using npm or yarn:

npm install shorten-ly
# or
yarn add shorten-ly

πŸš€ Usage

1️⃣ Import the Library

import { urlShortener } from "shorten-ly";

2️⃣ Set a Custom Domain (Optional)

By default, shorten-ly uses http://localhost:3000, but you can set your own domain:

urlShortener.setBaseURL("https://mycustomdomain.com");

If you skip this step, the default http://localhost:3000 will be used.

3️⃣ Shorten a URL

(async () => {
	const shortURL = await urlShortener.shortenURL(
		"https://example.com/long-url"
	);
	console.log(shortURL); // e.g., https://mycustomdomain.com/abc123
})();

4️⃣ Retrieve the Original URL

const originalURL = await urlShortener.getOriginalURL("abc123");
console.log(originalURL); // https://example.com/long-url

5️⃣ Get URL Analytics (Visit Count)

const analytics = await urlShortener.getAnalytics("abc123");
console.log(`Visits: ${analytics.visits}`);

πŸ“Œ Folder Structure

shorten-ly/
│── prisma/
β”‚   β”œβ”€β”€ schema.prisma
β”‚   β”œβ”€β”€ prisma.db (SQLite database)
│── src/
β”‚   β”œβ”€β”€ index.js
β”œβ”€β”€ example.js
│── .gitignore
│── package.json
│── README.md

πŸ›  Database Configuration

shorten-ly uses SQLite for storage. By default, it saves data in prisma.db.

Run:

npx prisma migrate dev --name init

🎯 Why Use shorten-ly?

βœ” No external services required - Everything runs locally
βœ” Custom domain support - Use your own short link domain
βœ” Easy integration - Works as a library in your existing projects


Contributing

Feel free to contribute by submitting issues or pull requests.


πŸ“œ License

This project is licensed under the MIT License.


πŸ‘¨β€πŸ’» Author

Developed by Parth Sharma