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 🙏

© 2025 – Pkg Stats / Ryan Hefner

next-static-manifest

v0.9.0

Published

<h1 align="center"> next-static-manifest </h1>

Downloads

6

Readme

Installation

$ npm install --save next-static-manifest
$ yarn add next-static-manifest

Usage

Let's take a look at this scenario, our application looks like this:

|-- pages
|   |-- index.js
|   |-- [...slug].js
|   |-- blog/posts/[id].js
|   |-- blog/posts/[id]/[authorId].js

We add next-static-manifest to our export script:

$ next build && next export && next-static-manifest

And after exporting our app, we get this:

|-- out
|   |-- next-static-manifest.json
|   |-- index.html
|   |-- [...slug].html
|   |-- blog/posts/[id].html
|   |-- blog/posts/[id]/[authorId].html

The next-static-manifest.json will look this:

[
  {
    "src": "/blog/posts/[id]/[authorId]",
    "dest": "/blog/posts/[id]/[authorId].html",
    "regex": "__REGEXP__:/^\\/blog\\/posts\\/([^/]+?)\\/([^/]+?)(?:\\/)?$/",
    "dynamic": true
  },
  {
    "src": "/blog/posts/[id]",
    "dest": "/blog/posts/[id].html",
    "regex": "__REGEXP__:/^\\/blog\\/posts\\/([^/]+?)(?:\\/)?$/",
    "dynamic": true
  },
  {
    "src": "/index",
    "dest": "/index.html",
    "regex": "__REGEXP__:/^\\/index(?:\\/)?$/",
    "dynamic": false
  },
  {
    "src": "/404",
    "dest": "/404.html",
    "regex": "__REGEXP__:/^\\/404(?:\\/)?$/",
    "dynamic": false
  },
  {
    "dynamic": false,
    "regex": "__REGEXP__:/^\\/(?:\\/)?$/",
    "src": "/",
    "dest": "index.html"
  },
  {
    "src": "/[...slug]",
    "dest": "/[...slug].html",
    "regex": "__REGEXP__:/^\\/(.+?)(?:\\/)?$/",
    "dynamic": true
  }
]

Without any type of infrastructure in place, we can't route users to our dynamically exported routes.

A request to: /blog/posts/123-456-789 wont match our filesystem location for the /blog/posts/[id].html file.

However, if we write a small Lambda@Edge function or use a Worker to ingest this file, we can automatically route users to the correct .html entrypoint.

How it works

next-static-manifest runs after your app has been exported by Next. We generate a next-static-manifest.json file that you can poll on Lambda@Edge or in your Worker, after deploying, your worker will get a new file and route accordingly.

In your function/worker, it's important to use decode when parsing the manifest file.

import { decode } from 'next-static-manifest';

fetch('.../next-static-manifest.json')
  .then((r) => r.json())
  .then((data) => decode(data));

We need to hydrate our data with decode, because regex isn't part of the JSON spec, so we have to encode/decode it ourselves.

Questions? Feedback? Please let me know

License (MIT)

WWWWWW||WWWWWW
 W W W||W W W
      ||
    ( OO )__________
     /  |           \
    /o o|    MIT     \
    \___/||_||__||_|| *
         || ||  || ||
        _||_|| _||_||
       (__|__|(__|__|

Copyright © 2020-present Jack Hanford, [email protected]