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

# Remote Browser Control

> Learn how to control an existing browser window using Narada

## Overview

Narada can control an existing browser window from another machine or process. Use `RemoteBrowserEnvironment` when you already have a browser window ID and want to run an `Agent` against that browser.

<Frame>
  <iframe
    width="100%"
    height="400px"
    src="https://www.youtube.com/embed/N7144RKWzG4"
    title="Narada SDK Demo"
    frameBorder="0"
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
    allowFullScreen
    style={{
  width: "100%",
  minHeight: "400px",
  borderRadius: "0.5rem",
}}
  />
</Frame>

## Prerequisites

<CardGroup cols={3}>
  <Card title="Install Narada" icon="download" href="/documentation/installation">
    Install Narada on the remote machine
  </Card>

  <Card title="Chrome Extension" icon="puzzle-piece" href="/documentation/installation">
    Install and sign in to the Narada extension in Chrome
  </Card>

  <Card title="Python SDK" icon="code" href="/documentation/getting-started-with-sdk">
    Set up the Python SDK on the controlling machine
  </Card>
</CardGroup>

## Getting Started

<Steps>
  <Step title="Initialize the remote browser">
    On the remote machine:

    1. Open Chrome with the Narada extension installed.
    2. Visit [https://app.narada.ai/initialize](https://app.narada.ai/initialize).
    3. Copy the browser window ID displayed by the initialization page.

    <Note>
      Keep this browser window ID secure because it grants access to the remote browser.
    </Note>
  </Step>

  <Step title="Create the control script">
    Create a Python script on your controlling machine:

    ```python theme={null}
    import asyncio

    from narada import Agent, RemoteBrowserEnvironment


    async def main() -> None:
        browser_window_id = "REPLACE_WITH_BROWSER_WINDOW_ID"

        env = RemoteBrowserEnvironment(browser_window_id=browser_window_id)
        agent = Agent(environment=env)

        response = await agent.run(
            prompt=(
                'Search for "LLM Compiler" on Google and open the first arXiv paper '
                "on the results page, then tell me who the authors are."
            )
        )

        print("Response:", response.text)


    if __name__ == "__main__":
        asyncio.run(main())
    ```

    <Tip>
      Replace `browser_window_id` with the ID from your remote browser.
    </Tip>
  </Step>

  <Step title="Run the remote task">
    Execute your control script:

    ```bash theme={null}
    python your_script.py
    ```

    <Check>
      If successful, the remote browser executes your command and returns the result.
    </Check>
  </Step>
</Steps>

## How It Works

1. **Browser Window ID**: Each initialized browser window has a unique ID that identifies the remote execution target.
2. **Remote Environment**: `RemoteBrowserEnvironment(browser_window_id=...)` points the SDK at that existing browser.
3. **Agent Execution**: `Agent(environment=env)` sends browser automation requests to the remote window.
4. **Response Handling**: `Agent.run()` returns an `AgentResponse` that you can inspect in Python.

## Reconnecting to Cloud Browser Sessions

If you're using [Cloud Browser Sessions](/documentation/cloud-browser-sessions), provide both the browser window ID and the cloud browser session ID:

```python theme={null}
import asyncio

from narada import Agent, RemoteBrowserEnvironment


async def main() -> None:
    env = RemoteBrowserEnvironment(
        browser_window_id="saved-browser-window-id",
        cloud_browser_session_id="saved-cloud-session-id",
    )
    agent = Agent(environment=env)

    try:
        response = await agent.run(prompt="What page am I currently on?")
        print("Response:", response.text)
    finally:
        await env.close()


if __name__ == "__main__":
    asyncio.run(main())
```

<Note>
  Closing a `RemoteBrowserEnvironment` backed by a cloud session stops the entire cloud session. Make sure you're done before calling `close()`.
</Note>

## Related Resources

* [Cloud Browser Sessions](/documentation/cloud-browser-sessions)
* [API Reference for Remote Dispatch](/api-reference/remote-dispatch)
* [Authentication Guide](/documentation/authentication)
* [Error Handling](/documentation/error-handling)
