# Open

The following example demonstrates how to request a browser instance, navigate to a webpage, and close the browser:

<pre class="language-javascript"><code class="lang-javascript">const rp = await browserService.open();
<strong>console.log('Browser opened');
</strong>
const browser = await puppeteer.connect({
  browserWSEndpoint: rp.address,
  defaultViewport: null,
  ignoreHTTPSErrors: true,
  slowMo: 0
});

const pages = await browser.pages();
const page = pages[0];
await page.goto('https://cloudbrowser.ai');
</code></pre>

***

#### F**ull example**

{% embed url="<https://github.com/CloudBrowser-AI/CloudBrowserAiNodeJS/blob/main/samples/open/index.js>" %}

This code initializes a Puppeteer browser instance using a remote service and navigates to a specific webpage. First, it opens a remote browser session via `browserService.open()` and logs that the browser has been opened. Then, it connects Puppeteer to the remote browser using the WebSocket endpoint from the session (`rp.address`) with specific options, such as disabling viewport restrictions and ignoring HTTPS errors. It retrieves all open pages within the browser, selects the first one, and navigates it to the URL `https://cloudbrowser.ai`.

## Open (with parameters)

The following example demonstrates how to request a browser instance with advanced configuration, including custom browser settings, proxy, and a timeout for keeping the browser open.

* **Label**: Set a custom label for the browser instance.
* **Browser**: Choose the browser type (e.g., Chromium or Chrome).
* **KeepOpen**: Set the timeout in seconds for how long the browser should remain open without a Puppeteer connection.
* **Proxy**: Configure proxy settings (host, port, username, password).

```javascript
const rp = await browserService.open({
    label: "MyCustomBrowser",
    //Chromium is supported but we recommend Chrome for best stealth
    browser: SupportedBrowser.CHROMIUM,
    keepOpen: 10 * 60, //This browser will close after 10 minutes without any Puppeteer connected.
    proxy: {
        host: "IP.0.0.0.1",
        port: "3000",
        password: "password",
        username: "username",
    },
});
```

***

#### F**ull example**

{% embed url="<https://github.com/CloudBrowser-AI/CloudBrowserAiNodeJS/blob/main/samples/open-advanced/src/index.ts>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cloudbrowser.gitbook.io/docs/libraries/node.js-client/open.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
