v133 · file apis
FileSystemObserver interface
The FileSystemObserver interface notifies websites of changes to the file system. Sites observe changes to files and directories, to which the user has previously granted permission, in the user's local device (as specified in WICG/file-system-access) or in the Bucket File System (as specified in whatwg/fs), and are notified of basic change info, such as the
concepts
-
FileSystemObserver
FileSystemObserver watches OPFS / picker handles for changes. The missing inotify for the web.
-
OPFS live editor
Two tabs of the same app sharing OPFS — one writes a file, the other sees it appear instantly via
FileSystemObserver. The collaborative-editor use case from the explainer. -
Sync conflict detector
Two editors writing the same file simultaneously. The observer's batched delivery lets the page label the write as a conflict before either side commits.
-
Recursive directory watcher
Compare
recursive: truevsfalse. Mutate a nested tree from the page and watch which events reach each watch — the IDE file-tree pattern. -
Hot-reload simulation
Edit Markdown, save it to OPFS, and use
FileSystemObservernotifications to re-render the preview — the browser-based development-tooling use case.
why it shipped
Currently, for a given agent to know about modifications to the file system - made either by itself or from some external context - it must poll the file system to detect changes. This is inefficient and does not scale well. The FileSystemObserver interface makes it easier for a website to be notified of changes to the file system.