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

express-crumb

v1.2.0

Published

A breadcrumb generator for Express

Readme

express-crumb

A simple breadcrumb generator for Express applications.

Installation

npm install express-crumb

Usage

First, require the module in your main .js file (app.js for example)

var Crumb = require('express-crumb')

Then an instance of express-crumb needs to be created

var crumb = new Crumb()

Now you need to use the getRoutes() function to get all of the GET routes of your application. This needs to be added after you have declared your routes, and mounted any router modules.

app.get("/", function(req, res, next){
  // do some stuff
})

app.use("/foo", foo)
app.use("/bar", bar)

crumb.getRoutes(app)

To generate the breadcrumb, you can do the following:

app.use(crumb.generateCrumbs(options))

This will generate a breadcrumb on all requests made on the server.

Or, if you want to use it on a specific route, you can add it to the middleware stack when declaring a route, like so:

app.get("/blog/post/123456", crumb.generateCrumbs(options), function(req, res, next){
  // do stuff
})

Mounted Router Modules

If you are using a mounted router module, you can pass the instance of express-crumb when you require the module.

var blog = require('./routes/foo')(crumb)

then in your router:

module.exports = function(crumb){
  var express = require('express')
  var router = express.Router()

  router.get("/bar", crumb.generateCrumbs(options), function(req, res, next){
    // do stuff
  })

  return router;
}

Generated Labels

One minor issue that you may find is the generated labels. This module will replace any - and _ and replace them with spaces. Then each word is capitalized. For example:

"/foo-bar"  // -> Foo Bar
"/fooBar"   // -> FooBar

Options

There are currently 6 options that can be altered to your liking. These options are passed as an object to the generateCrumbs() function. For example:

app.use(crumb.generateCrumbs({
  includeNonRoutes: true
}))

generateCrumbs(options)

| Option | Description | Default Value | | --- | --- | --- | | includeHome | Includes a clickable link to the home page (assumed at '/') | true | | homeLabel | The label that should be displayed if includeHome is enabled 1 | "Home" | | includeNonRoutes | Include routes that are present in the path, but do not exist in the application 2 | false | | linkLastCrumb | Make the last link in the crumb - the page you are on - clickable | false | | includeSeparators | Include separators - as separate li elements - into the markup | true | | separatorLabel | The label used in the separators 1 | "-" |

  1. HTML is supported, meaning html-based icons, like FortAwesome or Glyphicon, can be used.

  2. For example, if you have a route like: /foo/bar/baz, but only have routes linking to /foo and /foo/bar/baz, and you leave includeNonRoutes as its default value, the breadcrumb will look something like: Home - Foo - Baz. Whereas, if you set includeNonRoutes to true you will get: Home - Foo - Bar - Baz, and Bar will not be clickable.

Views

generateCrumbs() will store the breadcrumbs in a <ul><li> structure in res.locals.crumbs variable; making it accessible in the template files. Below is the generated markup and some examples of how inject it into your template.

<!-- Crumbs with includeSeparators as FALSE -->
<ul class='crumbs'>
  <li class='crumb'><a href='/'>Home</a></li>
  <li class='crumb'><a href='/tutorials'>Tutorials</a></li>
  <li class='crumb'><a href='/tutorials/javascript'>Javascript</a></li>
  <li class='crumb'>Create Breadcrumbs For Express</li>
</ul>
<!-- Crumbs with includeSeparators as TRUE -->
<ul class='crumbs'>
  <li class='crumb'><a href='/'>Home</a></li>
  <li class='separator'>-</li>
  <li class='crumb'><a href='/tutorials'>Tutorials</a></li>
  <li class='separator'>-</li>
  <li class='crumb'><a href='/tutorials/javascript'>Javascript</a></li>
  <li class='separator'>-</li>
  <li class='crumb'>Create Breadcrumbs For Express</li>
</ul>

Using Jade/Pug

!{crumbs}

Using EJS

<%- crumbs %>

Using Handlebars

{{{crumbs}}}

Changelog

  • 1.1.0
    • Added support for separators in the generated markup
  • 1.0.1
    • Initial Release