Nginx-style directory listings for Cloudflare Workers and R2.
GitHub · npm · live example bucket
docs/index.html./latest and
/downloads/example.txt.
/private/ uses demo:r2-serve.
/hidden/ exists in R2 but is not listed.import { createAutoIndexWorker } from "r2-serve";
export interface Env {
BUCKET: R2Bucket;
}
export default createAutoIndexWorker<Env>({
bucket: (env) => env.BUCKET,
indexes: ["index.html", "index.htm"],
});
A deployment needs an R2 bucket, a Queue, R2 event notification rules for object creates/deletes, and a Worker with the R2 binding plus Queue consumer.
The Terraform module in the repository can manage the whole standalone deployment using the committed Worker bundle.