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

# Trigger

A union type representing different methods to trigger file downloads in web automation.

This type standardizes how download operations can be initiated, providing multiple approaches for different automation scenarios.

**Type variants:**

* `string`: Direct URL string to download from
* `Locator`: Playwright Locator object pointing to a clickable download element
* `(page: Page) => Promise<void>`: Custom async function that takes a Page and triggers the download

```typescript theme={null}
export type Trigger = string | Locator | ((page: Page) => Promise<void>);
```

## Examples

```typescript URL String Trigger theme={null}
import { downloadFile } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  // Direct download from URL
  const download = await downloadFile({
    page,
    trigger: "https://example.com/report.pdf",
  });
}
```

```typescript Locator Trigger theme={null}
import { downloadFile } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  // Click a download button
  const download = await downloadFile({
    page,
    trigger: page.locator("#download-btn"),
  });
}
```

```typescript Callback Trigger theme={null}
import { downloadFile } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  // Custom download logic
  const download = await downloadFile({
    page,
    trigger: async (p) => {
      await p.locator("button.prepare").click();
      await p.waitForSelector(".ready");
      await p.locator("a.download-link").click();
    },
  });
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.