> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anchorbrowser.io/llms.txt
> Use this file to discover all available pages before exploring further.

# File Download

Anchor Browser supports two methods for downloading files during your browser sessions:

1. **Traditional Downloads**: Files are downloaded to the browser instance and then stored by Anchor for retrieval

<Note>
  To download PDF files directly instead of viewing them in the browser, set `pdf_viewer` to `false` when creating your session.
</Note>

2. **P2P Downloads**: Files are captured directly in the browser using peer-to-peer technology, available instantly without waiting for Anchor storage

## Traditional File Downloads

The following examples demonstrate how to download a file using the traditional method and retrieve it from the browser session.

<Steps>
  <Step title="Create a browser session">
    Use the [create session](api-reference/browser-sessions/start-browser-session) API to create a new browser session.
    To enable automatic PDF downloads, include the following `browser` configuration:

    <CodeGroup>
      ```tsx node.js theme={null}
      browser: {
          pdf_viewer: {
              active: false
              }
          }
      ```

      ```python python theme={null}
      "browser": {
          "pdf_viewer": {
              "active": False
              }
          }
      ```
    </CodeGroup>
  </Step>

  <Step title="Browse and download a file">
    Use the following example to perform a file download

    <CodeGroup>
      ```tsx node.js theme={null}
      await page.goto("https://browser-tests-alpha.vercel.app/api/download-test");

      await Promise.all([page.waitForEvent("download"), page.locator("#download").click()]); // The download has completed
      ```

      ```python python theme={null}
      await page.goto("https://browser-tests-alpha.vercel.app/api/download-test")

      async with page.expect_download() as download_info:
          await page.locator("#download").click()

      download = await download_info.value
      ```
    </CodeGroup>
  </Step>

  <Step title="Fetch the file from the browser session">
    You can retrieve the downloaded file from the browser session using the [get session downloads](/api-reference/browser-sessions/list-session-downloads) API
  </Step>
</Steps>

## P2P Downloads

For real-time download notifications and direct file streaming without waiting for Anchor storage, see the [P2P Download Guide](/advanced/p2p-downloads). Files are available immediately when the download completes — no polling required.
