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

@fastly/hono-compute-js-static-publish

v0.5.4

Published

Serve files from Fastly Compute Static Publisher on Hono

Downloads

912

Readme

Compute Static Publisher for Hono

NOTE: @fastly/hono-compute-js-static-publish is provided as a Fastly Labs product. Visit the Fastly Labs site for terms of use.

@fastly/hono-compute-js-static-publish is a utility for Hono to allow your program to serve static files under Fastly Compute. It leverages the PublisherServer from @fastly/compute-js-static-publish.

Works with:

Example

compute-js-static-publish v7

import { Hono } from 'hono/quick'
import { fire } from 'hono/service-worker'

import { fromStaticPublishRc } from '@fastly/hono-compute-js-static-publish'
import rc from '../static-publish.rc.js'
const serveStatic = fromStaticPublishRc(rc)

const app = new Hono()

app.get('/', (c) => {
  return c.text('Hello Hono!')
})

app.get('/favicon.ico', serveStatic({ path: './favicon.ico' }))
app.get('/static/*', serveStatic({ root: './' }))

fire(app)

compute-js-static-publish v6

import { Hono } from 'hono/quick'
import { fire } from 'hono/service-worker'

import { fromPublisherServer } from '@fastly/hono-compute-js-static-publish'
import { getServer } from '../static-publisher/statics.js'
const serveStatic = fromPublisherServer(getServer())

const app = new Hono()

app.get('/', (c) => {
  return c.text('Hello Hono!')
})

app.get('/favicon.ico', serveStatic({ path: './favicon.ico' }))
app.get('/static/*', serveStatic({ root: './' }))

fire(app)

Usage

[!NOTE] The instructions below are for @fastly/compute-js-static-publish v7.

Once you have set up a Hono project for Fastly Compute, add this library and the Static Publisher library to your application:

npm install @fastly/hono-compute-js-static-publish @fastly/compute-js-static-publish

These directions assume your static files exist directly under the ./assets subdirectory of your Fastly Compute application.

You will need to add and modify some files at the root of your project.

  • Add static-publish.rc.js

    /** @type {import('@fastly/hono-compute-js-static-publish').StaticPublishRc} */
    const rc = {
        kvStoreName: "site-content",
        publishId: "default",
        defaultCollectionName: "live",
        staticPublisherWorkingDir: "./static-publisher",
    };
      
    export default rc;

    This sets up the Static Publisher to use a KV Store named site-content and to place generated temporary files in the ./static-publisher subdirectory. The other fields are not used in @fastly/hono-compute-js-static-publish but are required fields.

    [!TIP] Add ./static-publisher/ to your .gitignore as these files will be regenerated on the build.

  • Add publish-content.config.js

    /** @type {import('@fastly/hono-compute-js-static-publish').PublishContentConfig} */
    const config = {
        rootDir: './assets'
    };
      
    export default config;

    This instructs the Static Publisher to find static files at ./assets.

    [!IMPORTANT] As this application does not use PublisherServer to directly serve assets, the server field is not applicable.

  • Modify package.json Add the following items under the scripts section:

    {
      "scripts": {
        "dev:publish": "npx @fastly/compute-js-static-publish publish-content --local",
        "dev:start": "fastly compute serve",
        "fastly:deploy": "fastly compute publish",
        "fastly:publish": "npx @fastly/compute-js-static-publish publish-content"
      }
    }
  • Modify fastly.toml Add the following lines to the end of the file:

    [local_server.kv_stores]
    site-content = { file = "./static-publisher/kvstore.json", format = "json" }
    
    [setup.kv_stores.site-content]

Finally, modify your application's src/index.ts file:

  1. Import fromStaticPublishRc from this library
  2. Import the default constant from static-publish.rc.js and pass it to fromStaticPublishRc() to instantiate the Hono Middleware.
import { Hono } from 'hono/quick'
import { fire } from 'hono/service-worker'

import { fromStaticPublishRc } from '@fastly/hono-compute-js-static-publish'
import rc from '../static-publish.rc.js'
const serveStatic = fromStaticPublishRc(rc)

const app = new Hono()

app.get('/', (c) => {
  return c.text('Hello Hono!')
})

app.get('/favicon.ico', serveStatic({ path: './favicon.ico' }))
app.get('/static/*', serveStatic({ root: './' }))

fire(app)

Include either path or root in the object passed to serveStatic().

  • path - serves the static file at the specified path under the asset directory.
    • e.g., a request for /favicon.ico serves ./assets/favicon.ico.
  • root - serves the file at the path under the asset directory relative to the specified directory.
    • e.g., a request for /static/foo.html serves ./assets/static/foo.html.

Run locally

npm run dev:publish          # 'publish' your files to the simulated local KV Store
npm run dev:start            # preview locally

Serves your app at http://127.0.0.1:7676, powered by a simulated KV Store.

Deploy to Fastly Compute

Create a free Fastly account if you haven't already, and then:

npm run fastly:deploy        # deploy the app
npm run fastly:publish       # upload your static files

Further changes involving only updates to your static files can be made by running:

npm run fastly:publish       # upload your static files

📘 For more on Compute-JS Static Publisher:
https://github.com/fastly/compute-js-static-publish

Issues

If you encounter any non-security-related bug or unexpected behavior, please file an issue using the bug report template.

Security issues

Please see our SECURITY.md for guidance on reporting security-related issues.

License

MIT.