> ## 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.

# goToUrl

Navigates to a specified URL with enhanced reliability features including automatic retries with exponential backoff,
intelligent timeout handling, and optional AI-powered loading verification.

This function handles common navigation challenges by automatically retrying failed requests, detecting navigation hangs, and ensuring the page reaches a truly idle state.

This method can also use AI vision to verify the page is fully loaded by checking for loading spinners, blank content, or incomplete states.

```typescript theme={null}
export declare function goToUrl(input: {
  page: Page;
  url: string;
  timeoutInMs?: number;
  retries?: number;
  throwOnTimeout?: boolean;
  waitForLoadState?: "load" | "domcontentloaded" | "networkidle" | "commit";
  waitForLoadingStateUsingAi?: boolean;
  model?: string;
  apiKey?: string;
}): Promise<void>;
```

## Examples

<CodeGroup>
  ```typescript Without options theme={null}
  import { goToUrl } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    await goToUrl({
      page,
      url: "https://sandbox.intuned.dev/",
    });
    // At this point, goToUrl has waited for the page to be loaded and the network requests to be settled.
  }
  ```

  ```typescript With options theme={null}
  import { goToUrl } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    await goToUrl({
      page,
      url: "https://intunedhq.com",
      waitForLoadState: "domcontentloaded", // Faster than "load" state. The function automatically waits for the page to settle.
      throwOnTimeout: true,
      timeoutInMs: 10000,
      retries: 3,
    });
    // At this point, DOM content is loaded and goToUrl has waited for network requests to settle.
  }
  ```

  ```typescript With AI Loading Detection theme={null}
  import { goToUrl } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    await goToUrl({
      page,
      url: "https://intunedhq.com",
      waitForLoadingStateUsingAi: true,
      model: "gpt-4o",
    });
    // The page is loaded and ready to use.
    // If the AI check fails, the method won't throw even if throwOnTimeout is true.
    // It only throws if the page times out reaching the default load state and throwOnTimeout is true.
  }
  ```
</CodeGroup>

## Arguments

<ResponseField name="input" type="Object" required>
  The input object containing the page and url.

  <Expandable title="properties" defaultOpen>
    <ResponseField name="input.page" type="Page" required>
      The Playwright page object to navigate.
    </ResponseField>

    <ResponseField name="input.url" type="string" required>
      The URL to navigate to.
    </ResponseField>

    <ResponseField name="input.timeoutInMs" type="number">
      Maximum time in milliseconds to wait for navigation. Defaults to 30000.
    </ResponseField>

    <ResponseField name="input.retries" type="number">
      Number of retry attempts with exponential backoff (factor: 2). Defaults to 3.
    </ResponseField>

    <ResponseField name="input.waitForLoadState" type="'load'|'domcontentloaded'|'networkidle'|'commit'">
      When to consider navigation succeeded. Defaults to `"load"`
    </ResponseField>

    <ResponseField name="input.throwOnTimeout" type="boolean">
      Whether to throw an error if navigation times out. When true, the function throws an error on navigation timeout. Defaults to false.
    </ResponseField>

    <ResponseField name="input.waitForLoadingStateUsingAi" type="boolean">
      When true, uses AI vision to verify the page is fully loaded by checking for loading spinners, blank content, or incomplete states. Retries up to 3 times with 5-second delays. Defaults to false
      Check [isPageLoaded](../../ai/functions/isPageLoaded) for more details on the AI loading verification.
    </ResponseField>

    <ResponseField name="input.model" type="string">
      AI model to use for loading verification. Defaults to `"gpt-5-mini-2025-08-07"`
    </ResponseField>

    <ResponseField name="input.apiKey" type="string">
      Optional API key for the AI check.
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns: `Promise<void>`

Promise that resolves when navigation completes. If the operation fails and `throwOnTimeout` is false, resolves without error
