Hono
Mount the Files gateway in a Hono app. Web-native, so it runs anywhere Hono does - Cloudflare Workers, Bun, Deno, and Node.
files-sdk/hono mounts a createFilesRouter in a Hono app. Like the Next binding it is Web-native, so it runs anywhere Hono does — Cloudflare Workers, Bun, Deno, and Node.
createRouteHandler returns a single handler. Mount it with app.all so all three methods reach the gateway — it dispatches on the method internally (GET = download, POST = the JSON verbs, PUT = upload) and addresses everything by query string, so one fixed path is enough.
import { Hono } from "hono";
import { createFiles } from "files-sdk";
import { s3 } from "files-sdk/s3";
import { createFilesRouter } from "files-sdk/api";
import { createRouteHandler } from "files-sdk/hono";
const router = createFilesRouter({
files: createFiles({ adapter: s3({ bucket: "uploads" }) }),
allowedOrigins: ["https://app.example.com"],
authorize: async ({ req }) => {
/* throw to deny, or return a per-user constraint — see /ui/server/authorization */
},
});
const app = new Hono();
app.all("/api/files", createRouteHandler(router));
export default app;See the gateway options for the full configuration and the authorize model for locking it down.
Fastify
Mount the Files gateway on a Fastify server. Hijacks the reply and bridges Fastify's raw IncomingMessage/ServerResponse to the Web Request/Response the gateway speaks.
Koa
Mount the Files gateway on a Koa app. Sets ctx.respond = false and bridges ctx.req/ctx.res to the Web Request/Response the gateway speaks.