---
title: "Temporary storage for PDF downloads in JavaScript"
canonical_url: "https://www.nutrient.io/guides/web/open-a-document/temp-storage/"
md_url: "https://www.nutrient.io/guides/web/open-a-document/temp-storage.md"
last_updated: "2026-05-30T02:20:01.409Z"
description: "Learn how Nutrient Web SDK uses temporary storage for URL-loaded PDFs in the browser, and how to configure or disable origin private file system (OPFS)-backed temporary storage."
---

# Temporary storage for PDF downloads

When you load a PDF from a URL in the browser, Nutrient Web SDK has to keep the downloaded PDF somewhere so it can continue reading from it while the user works with the document.

By default, Web SDK manages this automatically. For larger eligible PDFs, it uses the browser’s [origin private file system (OPFS)](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system) to reduce peak browser RAM usage.

## When temporary storage is used

This behavior applies when you load a PDF from a URL in the browser:

```js

NutrientViewer.load({
  container: "#pspdfkit",

  document: "https://www.nutrient.io/downloads/nutrient-web-demo.pdf"
});

```

It doesn’t apply in the same way when you pass document data directly as an `ArrayBuffer` or `Blob`, because your application is already providing the document data to the viewer.

## Why Web SDK uses OPFS

If you download a PDF from the internet, the viewer needs to keep that PDF somewhere so it can continue reading from it while the user works with the document.

Without OPFS, the downloaded PDF data has to stay in browser process memory (RAM). For larger PDFs, this can noticeably raise peak RAM usage.

With [origin private file system (OPFS)](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system), Web SDK can keep temporary download data in secure browser-managed storage on the user’s device instead of keeping all of it in browser process memory (RAM). OPFS is supported by all major browsers.

This enables Web SDK to reduce browser RAM pressure for larger eligible URL-loaded PDFs while keeping the default behavior automatic with [`tempStorage`](https://www.nutrient.io/api/web/interfaces/Configuration.html#tempstorage), which is set to `"auto"`.

## Configuring temporary storage

Use the [`tempStorage`](https://www.nutrient.io/api/web/interfaces/Configuration.html#tempstorage) option to control this behavior.

### Default behavior

`"auto"` is the default. Web SDK decides when to use OPFS for larger eligible URL-loaded PDFs:

```js

NutrientViewer.load({
  container: "#pspdfkit",

  document: "https://www.nutrient.io/downloads/nutrient-web-demo.pdf",
  tempStorage: "auto"
});

```

### Disable OPFS-backed temporary storage

If you don’t want Web SDK to use OPFS for temporary storage, set `tempStorage` to `"memory"`:

```js

NutrientViewer.load({
  container: "#pspdfkit",

  document: "https://www.nutrient.io/downloads/nutrient-web-demo.pdf",
  tempStorage: "memory"
});

```

This keeps temporary download data in the browser process memory (RAM).

### Prefer OPFS

If you want to prefer OPFS for eligible URL-loaded PDFs regardless of file size, set `tempStorage` to `"opfs"`:

```js

NutrientViewer.load({
  container: "#pspdfkit",

  document: "https://www.nutrient.io/downloads/nutrient-web-demo.pdf",
  tempStorage: "opfs"
});

```

## Fallback behavior

If OPFS is unavailable or initialization fails, Web SDK falls back to the in-memory (browser RAM) path automatically.

In that case, the document may be requested again.

## Related guides

- [Open from a remote URL](https://www.nutrient.io/guides/web/open-a-document/from-remote-url.md)

- [Optimize PDF loading with linearized documents](https://www.nutrient.io/guides/web/performance/linearized-downloads.md)
---

## Related pages

- [Open documents from Document Engine](/guides/web/open-a-document/from-document-engine.md)
- [Open PDFs from Base64 in the browser using JavaScript](/guides/web/open-a-document/from-base64-data.md)
- [Open PDFs using DWS Viewer API](/guides/web/open-a-document/from-dws-viewer-api.md)
- [Open and display PDFs from a Blob using JavaScript](/guides/web/open-a-document/from-blob.md)
- [Open PDFs from an ArrayBuffer using JavaScript](/guides/web/open-a-document/from-arraybuffer.md)
- [Open local PDF files using JavaScript](/guides/web/open-a-document/from-local-storage.md)
- [Open image files from an array buffer using JavaScript](/guides/web/open-a-document/image-from-arraybuffer.md)
- [Open and display PDF files from a remote URL using JavaScript](/guides/web/open-a-document/from-remote-url.md)
- [Open Base64 image files using JavaScript](/guides/web/open-a-document/image-from-base64-data.md)
- [Open image files from a Blob using JavaScript](/guides/web/open-a-document/image-from-blob.md)
- [Open and display PDFs in the browser using JavaScript](/guides/web/open-a-document.md)
- [Open local image files using JavaScript](/guides/web/open-a-document/image-from-local-storage.md)
- [Open image files from a URL using JavaScript](/guides/web/open-a-document/image-from-remote-url.md)
- [Open Base64 MS Office files using JavaScript](/guides/web/open-a-document/office-from-base64-data.md)
- [Opening specific pages in PDFs using JavaScript](/guides/web/features/open-parameters.md)
- [Open MS Office files from an ArrayBuffer using JavaScript](/guides/web/open-a-document/office-from-arraybuffer.md)
- [Open MS Office files from a Blob using JavaScript](/guides/web/open-a-document/office-from-blob.md)
- [Open local MS Office files using JavaScript](/guides/web/open-a-document/office-from-local-storage.md)
- [Open MS Office files from a URL using JavaScript](/guides/web/open-a-document/office-from-remote-url.md)

