JS

Js File Download

js-file-download

Javascript function that triggers browser to save javascript-generated content to a file

Utilities
javascript
file
react
download
js-file-download
Utilities
npm
frontend
open source
ui
Stars
342
Weekly
1.1M
Open issues
4
Bundle
~25 kB

Installation

npm install js-file-download

Code example

import { useJsFileDownload } from "js-file-download";

export function Example() {
  const value = useJsFileDownload();
  return <p>{String(value)}</p>;
}

Pros & cons

Pros

  • Actively maintained by Kenneth Jiang
  • 1.1M weekly downloads. Battle tested
  • First-class TypeScript definitions
  • MIT licensed

Considerations

  • Adds roughly ~25 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 4 open issues on GitHub

FAQs

Alternatives & similar libraries