browser-fs-access is a JavaScript library that provides a simplified, progressive enhancement approach to using the File System Access API in web browsers. It acts as a ponyfill, meaning it offers a consistent API surface while transparently falling back to older, less capable methods like `<input type="file">` and `<a download>` on browsers that do not fully support the File System Access API. This ensures broad compatibility while leveraging modern capabilities where available. The library is currently at version 0.38.0 and maintains an active release cadence, frequently publishing updates and fixes, often on a monthly basis. Key differentiators include its robust fallback mechanism, its origin from GoogleChromeLabs, and its focus on developer ergonomics by abstracting away the complexities of feature detection and legacy API interactions. It ships with TypeScript types for improved developer experience.
npm install browser-fs-accessVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates opening single and multiple files, recursively opening a directory, and saving a file, along with feature detection and error handling using the `browser-fs-access` library.
Update your code to expect `[directoryHandle]` for empty directories when the File System Access API is active, and handle cases where `files.length` might be 1 but represent an empty directory, or check the `kind` property of the handle.
Design your application's UI and workflow to gracefully handle the different user interactions and capabilities offered by the native File System Access API versus the fallback `<input type="file">` and `<a download>` methods. Use the `supported` export for feature detection.
Ensure you are using `browser-fs-access` version 0.35.0 or newer when working with iframes to benefit from the detection and functionality fixes. Thoroughly test file operations in your specific iframe contexts.
Inform users about the expected behavior for saving, especially regarding overwriting existing files, and differentiate between browsers with and without full File System Access API support.
Configure Jest's `transformIgnorePatterns` to include `browser-fs-access` for transformation, e.g., `"transformIgnorePatterns": ["node_modules/(?!browser-fs-access)"]`. For other bundlers, ensure your configuration correctly handles ESM in `node_modules`.
No dependency data recorded yet.