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

serves

v1.1.1

Published

bare-bones HTTP server with optional script entry

Readme

serves

stable

A tiny HTTP server CLI and API, mainly for local development.

Serves a default index.html and an optional JavaScript entry-point. By default, uses localhost and port 8080 (or searches for the next available port).

When using the programmatic API, the entry and index can be a middleware(req, res) function. For example, to bundle with browserify.

Install

npm install serves [-g|--save]

CLI Example

The following creates a server that hosts a default index.html with a <script> tag pointing to src/index.js. All other static content (images, etc) is served from the public root directory.

serves src/index.js --root public --port 9000

API Example

A simple example:

var serves = require('serves')
var path = require('path')

serves({
  cwd: process.cwd(),
  root: 'public',
  entry: 'src/index.js',
  title: 'My Site'
}, function (err, ev) {
  if (err) throw err
  console.log('Listening on', ev.url)
})

Or see example/index.js, which mimics wzrd and bundles CommonJS on request.

Usage

NPM

CLI

Usage:
  serves [entry.js] [opts]
  
Options:
  --title, -t    HTML title
  --root, -r     root directory for static files (default cwd)
  --port, -p     base port to attempt (default 8080)
  --host, -h     host name (default localhost)
  --css, -s      optional path to a CSS file
  --index, -i    HTML file to serve as index.html

API

server = httpServer([opt], [cb])

Creates a new HTTP server with the specified options and optional callback. Returns the server instance.

Options:

  • cwd (String|undefined)
    • the base directory to resolve file paths, defaults to process.cwd()
  • entry (String|Function|undefined)
    • a JavaScript entry file path, relative to cwd
    • or, can be a middleware(req, res) function
    • if not specified, no <script> will be added to the HTML
  • index (String|Function|undefined)
    • defaults to a bare-bones HTML index
    • the HTML index file path, relative to cwd
    • or, can be a middleware(req, res, ev) function
      • the ev parameter holds the { title, entry } strings
  • root (String|undefined)
    • the root directory to serve static content form, defaults to cwd
  • port (Number|undefined)
    • the base port to start searching from, default 8080
  • host (String|undefined)
    • the host name, default 'localhost'
  • title (String|undefined)
    • the HTML title, if unspecified no <title> will be written
  • css (String|undefined)
    • an optional href path for a <link rel="stylesheet"> tag in the <head>
    • relative to root since it is just an href in the tag
    • only gets applied to the default index handler

If you specify a function for entry, the script will serve 'index.js' by default. This pathname be changed with opt.src.

The callback takes the form callback(err, ev) with the following event parameters when the server starts listening:

{
  url: String  // 'http://localhost:8080/'
  port: Number // 8080
  host: String // 'localhost'
}

License

MIT, see LICENSE.md for details.