@campfire-interactive/save-file
v0.1.0
Published
Save a Blob, a string or a fetched URL as a file download in the browser
Keywords
Readme
@campfire-interactive/save-file
Save a Blob, a string or a fetched URL as a file download in the browser.
npm i @campfire-interactive/save-fileimport { downloadFromUrl, saveBlob, saveText } from '@campfire-interactive/save-file';
saveText(csv, 'opportunities.csv'); // CSV gets a BOM so Excel reads UTF-8
saveBlob(xlsxBlob, 'costing.xlsx');
await downloadFromUrl(presignedUrl, 'Q-2026-169.pdf');
await downloadFromUrl(url, name, { openOnNetworkError: true }); // new tab if the fetch is blockedFramework-free: no React and no design tokens, so any frontend can take it whatever its design-system status. It replaces the object-URL / hidden-anchor pattern six apps wrote for themselves, and settles the two details those copies disagreed on: the object URL is revoked a minute after the click rather than during it, and a CSV carries a byte-order mark.
