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

  1. FileSystemObserver

    FileSystemObserver watches OPFS / picker handles for changes. The missing inotify for the web.

  2. 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.

  3. 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.

  4. Recursive directory watcher

    Compare recursive: true vs false. Mutate a nested tree from the page and watch which events reach each watch — the IDE file-tree pattern.

  5. Hot-reload simulation

    Edit Markdown, save it to OPFS, and use FileSystemObserver notifications 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.

references