import { downloadZip } from "client-zip"; async function saveArchive() { // Define your files (can be Blobs, Strings, or Fetch responses) const files = [ { name: "hello.txt", lastModified: new Date(), input: "Hello World" }, { name: "image.png", input: fetch("https://example.com") } ]; // Generate the ZIP blob const blob = await downloadZip(files).blob(); // Create a download link const link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = "photos.zip"; link.click(); } Use code with caution. Copied to clipboard
Stop sending raw data to your server just to zip it. You can generate ZIP archives directly in the browser using the library. Why use it? client.zip
: It uses a streaming approach to keep memory usage low, even for large files. Privacy : Sensitive data never leaves the client's machine. import { downloadZip } from "client-zip"; async function