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

@jswork/url-literal

v1.0.10

Published

A utility for building safe, readable URLs with template literals and query parameters.

Readme

url-literal

A utility for building safe, readable URLs with template literals and query parameters.

version license size download

installation

yarn add @jswork/url-literal

usage

import urlLiteral from '@jswork/url-literal';

// Basic path building
const url1 = urlLiteral`/api/users`;
url1.toString(); // '/api/users'

// Path with variables
const userId = 123;
const url2 = urlLiteral`/api/users/${userId}`;
url2.toString(); // '/api/users/123'

// Add query parameters
const url3 = urlLiteral`/api/users`.withQuery({ page: 1, limit: 10 });
url3.toString(); // '/api/users?page=1&limit=10'

// Combine variables and query parameters
const url4 = urlLiteral`/api/users/${userId}/posts`.withQuery({ page: 1 });
url4.toString(); // '/api/users/123/posts?page=1'

// Replace path parameters
const path = urlLiteral`/api/users/:id`.withParam({ id: 123 });
path.toString(); // '/api/users/123'

// Replace multiple path parameters
const path2 = urlLiteral`/api/users/:userId/posts/:postId`.withParam({ userId: 123, postId: 456 });
path2.toString(); // '/api/users/123/posts/456'

// Chain params and query (params first, then query)
const url5 = urlLiteral`/api/users/:id`.withParam({ id: 123 }).withQuery({ page: 1, limit: 10 });
url5.toString(); // '/api/users/123?page=1&limit=10'

// Chain query and params (query first, then params)
const url6 = urlLiteral`/api/users/:id`.withQuery({ page: 1 }).withParam({ id: 123 });
url6.toString(); // '/api/users/123?page=1'

// Ignore null/undefined values
const url7 = urlLiteral`/api/users`.withQuery({ page: 1, search: null });
url7.toString(); // '/api/users?page=1'

// Automatic string conversion (no need to call toString())
const url8 = urlLiteral`/api/users/:id`.withParam({ id: 123 }).withQuery({ page: 1 });
const message = `Fetching ${url8}`; // 'Fetching /api/users/123?page=1'
const fullUrl = 'GET ' + url8; // 'GET /api/users/123?page=1'
fetch(url8); // Automatically converts to string

// Works in template literals
const url9 = urlLiteral`/api/users/:id`.withParam({ id: 123 });
console.log(`${url9}`); // '/api/users/123'

// String() also works
const url10 = urlLiteral`/api/users`.withQuery({ page: 1 });
String(url10); // '/api/users?page=1'

// toString() explicitly returns the URL string
const url11 = urlLiteral`/api/users/:id`.withParam({ id: 123 }).withQuery({ page: 1 });
url11.toString(); // '/api/users/123?page=1'

// Replace path parameters and get string directly with param() (legacy)
const url12 = urlLiteral`/api/users/:id`.param({ id: 123 });
url12; // '/api/users/123' (returns plain string)

// Add query parameters and get string directly with query() (legacy)
const url13 = urlLiteral`/api/users`.query({ page: 1, limit: 10 });
url13; // '/api/users?page=1&limit=10' (returns plain string)

// Combine param() and query() for direct string output (legacy)
const url14 = urlLiteral`/api/users/:id`.param({ id: 123 }).query({ page: 1 });
url14; // '/api/users/123?page=1'

license

Code released under the MIT license.