Skip to main content
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
To download PDF files directly instead of viewing them in the browser, set pdf_viewer to false when creating your session.
  1. 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.
1

Create a browser session

Use the create session API to create a new browser session. To enable automatic PDF downloads, include the following browser configuration:
browser: {
    pdf_viewer: {
        active: false
        }
    }
2

Browse and download a file

Use the following example to perform a file download
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
3

Fetch the file from the browser session

You can retrieve the downloaded file from the browser session using the get session downloads API

P2P Downloads

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