BlobRouter v0.1 · Last updated: August 2026 · Architecture version: 2.0
@blobrouter/sdk on the server (Route Handlers, Server Actions). The browser should upload to your API, not hold BLOBROUTER_API_KEY.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Upload from a Next.js Route Handler or Server Action — never from the browser with your API key.
@blobrouter/sdk on the server (Route Handlers, Server Actions). The browser should upload to your API, not hold BLOBROUTER_API_KEY.
// app/api/upload/route.ts
import { BlobRouter } from "@blobrouter/sdk";
import { NextRequest, NextResponse } from "next/server";
const storage = new BlobRouter({
apiKey: process.env.BLOBROUTER_API_KEY!,
});
export async function POST(req: NextRequest) {
const form = await req.formData();
const file = form.get("file");
if (!(file instanceof File)) {
return NextResponse.json({ error: "file required" }, { status: 400 });
}
const buffer = Buffer.from(await file.arrayBuffer());
const result = await storage.upload(buffer, {
fileName: file.name,
contentType: file.type || "application/octet-stream",
fileSizeBytes: buffer.length,
priority: "hot",
});
return NextResponse.json(result);
}
const body = new FormData();
body.append("file", fileInput.files[0]);
await fetch("/api/upload", { method: "POST", body });