Esta página ainda não está disponível em Português, por isso está a ler a versão em inglês.

File handling and the File System Access API in PWAs

Open, edit and save real files, like a desktop app.

Recursos e APIs Intermediário 1 min de leitura Revisado em 27 de nov. de 2026

Editors, design tools and viewers need files. The web now has three levels of file support.

1. Open files from the OS (file_handlers)

Declare file types in the manifest, and your installed app appears in "Open with" menus:

"file_handlers": [
  { "action": "/open", "accept": { "text/markdown": [".md", ".markdown"] }, "launch_type": "single-client" }
]

Receive the files when the app launches:

if ('launchQueue' in window) {
  launchQueue.setConsumer(async (params) => {
    for (const handle of params.files) {
      const file = await handle.getFile();
      openDocument(await file.text(), handle);
    }
  });
}

Supported by Chrome and Edge on desktop for installed apps. The first time, the user is asked to allow it.

2. Pick, read and save files (File System Access API)

const [handle] = await window.showOpenFilePicker({ types: [{ description: 'Markdown', accept: { 'text/markdown': ['.md'] } }] });
const text = await (await handle.getFile()).text();
// ... edit ...
const writable = await handle.createWritable();
await writable.write(newText);
await writable.close(); // saved to the same file

showOpenFilePicker, showSaveFilePicker and showDirectoryPicker are Chromium desktop features. Use browser-fs-access to fall back to <input type="file"> and downloads in other browsers.

3. Private, fast storage (OPFS)

The Origin Private File System gives your app a private file system that users do not see, supported in all modern browsers. It is ideal for caches, large data and SQLite databases:

const root = await navigator.storage.getDirectory();
const fh = await root.getFileHandle('data.bin', { create: true });
const w = await fh.createWritable(); await w.write(bytes); await w.close();

In a worker, createSyncAccessHandle() gives very fast synchronous reads and writes; SQLite Wasm uses it.

Real-world examples: Excalidraw, Photopea and VS Code for the Web all open and save local files.

Compatibilidade de navegadores

Compatibilidade dos navegadores com recursos de PWA
RecursoChrome / Edge desktopChrome AndroidSafari iOS / iPadOSSafari macOSFirefox desktopFirefox AndroidSamsung Internet
File handlers Chrome / Edge desktop: Sim Chrome Android: Não Safari iOS / iPadOS: Não Safari macOS: Não Firefox desktop: Não Firefox Android: Não Samsung Internet: Não
File System Access pickers Chrome / Edge desktop: Sim Chrome Android: Não (OPFS only) Safari iOS / iPadOS: Não (OPFS only) Safari macOS: Não (OPFS only) Firefox desktop: Não (OPFS only) Firefox Android: Não Samsung Internet: Não
Origin Private File System Chrome / Edge desktop: Sim Chrome Android: Sim Safari iOS / iPadOS: Sim Safari macOS: Sim Firefox desktop: Sim Firefox Android: Sim Samsung Internet: Sim

Ver a tabela completa