Static file serving middleware for Koa with support for directory listing, URL rewriting, and custom index files. Current stable version is 1.5.2. This package provides a simple API for serving static assets in Koa applications, similar to koa-static but with built-in options for rootPath rewriting, notFoundFile fallback, gzip support, and index file customization. It is designed for Koa v1 and may not be compatible with Koa v2 without additional conversion middleware.
npm install koa-static-serverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a Koa static server serving files from 'public' under '/static' with index file support, caching, and gzip.
If using Koa v2, use 'koa-convert' to wrap the middleware: app.use(convert(serve({...})))Set rootPath to the URL prefix you want, not the filesystem path.
Set 'notFoundFile' option to a fallback file, or ensure an index file exists in rootDir.
Migrate to 'koa-static' (v5+) for Koa v2 support and active maintenance.
Use default import: import serve from 'koa-static-server'
Install koa: npm install koa
Use app.use(serve({ rootDir: 'public' }))