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

versionkit

v0.1.0

Published

Framework-agnostic API versioning with RFC 8594 Sunset and RFC 9745 Deprecation headers

Readme

versionkit

Framework-agnostic API versioning with full RFC compliance.

Supports RFC 8594 (Sunset header), RFC 9745 (Deprecation header), and three version extraction strategies. Works with Hono, Fastify, Express, and any framework using Web Standards Request/Response.

Why

APIs evolve. Clients need time to migrate. versionkit gives you:

  • Version routing - dispatch requests to the right handler based on version
  • Deprecation signals - automatically inject RFC-compliant headers so clients know when versions are going away
  • Framework freedom - built on Web Standards, works everywhere

Install

npm install versionkit

Strategies

| Strategy | Source | Example | |----------|--------|---------| | header | Custom request header | Api-Version: 2025-01-01 | | url | URL path prefix | /v2/users | | accept | Accept header media type | application/vnd.api.v2+json |

Usage

Header Strategy

import { createVersionRouter } from 'versionkit';

const router = createVersionRouter({
  strategy: 'header',
  headerName: 'Api-Version', // default
  defaultVersion: '1',
  versions: {
    '1': {
      deprecated: true,
      deprecation: {
        sunset: new Date('2026-06-01'),
        deprecatedSince: new Date('2025-01-01'),
        link: 'https://docs.example.com/changelog',
      },
    },
    '2': {},
  },
});

router
  .handle('1', (req) => new Response(JSON.stringify({ version: 1 })))
  .handle('2', (req) => new Response(JSON.stringify({ version: 2 })));

const handler = router.middleware();
// handler(request) => Promise<Response>

URL Strategy

const router = createVersionRouter({
  strategy: 'url',
  versions: { '1': {}, '2': {} },
});

router
  .handle('1', () => new Response('v1'))
  .handle('2', () => new Response('v2'));

// GET /v2/users -> dispatches to version "2" handler

Accept Header Strategy

const router = createVersionRouter({
  strategy: 'accept',
  versions: { 'v1': {}, 'v2': {} },
});

router
  .handle('v1', () => new Response('v1'))
  .handle('v2', () => new Response('v2'));

// Accept: application/vnd.api.v2+json -> dispatches to "v2" handler

RFC Compliance

RFC 8594 - Sunset Header

When a version has a sunset date, the response includes:

Sunset: Mon, 01 Jun 2026 00:00:00 GMT

When a link is provided, the response includes:

Link: <https://docs.example.com/changelog>; rel="deprecation"

RFC 9745 - Deprecation Header

When deprecatedSince is set:

Deprecation: @1735689600

When no date is specified but the version is deprecated:

Deprecation: true

Framework Integration

Hono

import { Hono } from 'hono';
import { createVersionRouter } from 'versionkit';

const app = new Hono();
const router = createVersionRouter({ strategy: 'header', versions: { '1': {} } });
router.handle('1', (req) => new Response('v1'));

app.all('/api/*', (c) => router.middleware()(c.req.raw));

Express

import express from 'express';
import { createVersionRouter } from 'versionkit';

const app = express();
const router = createVersionRouter({ strategy: 'header', versions: { '1': {} } });
router.handle('1', (req) => new Response('v1'));

const handler = router.middleware();

app.use('/api', async (req, res) => {
  const webReq = new Request(`http://${req.headers.host}${req.url}`, {
    method: req.method,
    headers: req.headers as any,
  });
  const webRes = await handler(webReq);
  res.status(webRes.status);
  webRes.headers.forEach((v, k) => res.setHeader(k, v));
  res.send(await webRes.text());
});

Fastify

import Fastify from 'fastify';
import { createVersionRouter } from 'versionkit';

const fastify = Fastify();
const router = createVersionRouter({ strategy: 'url', versions: { '1': {} } });
router.handle('1', (req) => new Response('v1'));

const handler = router.middleware();

fastify.all('/v*', async (req, reply) => {
  const webReq = new Request(`http://${req.hostname}${req.url}`, {
    method: req.method,
    headers: req.headers as any,
  });
  const webRes = await handler(webReq);
  reply.status(webRes.status);
  webRes.headers.forEach((v, k) => reply.header(k, v));
  reply.send(await webRes.text());
});

API

createVersionRouter(opts: VersionRouterOptions): VersionRouter

Creates a new version router.

VersionRouter.handle(version: string, handler: RequestHandler): this

Registers a handler for a specific version. Chainable.

VersionRouter.middleware(): (req: Request) => Promise<Response>

Returns a request handler that dispatches to the correct versioned handler.

VersionRouter.resolveVersion(req: Request): string | null

Resolves which version applies to a given request without dispatching.

License

MIT