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

# Navigate in Background

<Note>
  **Internal Service** — This is not an HTTP endpoint. It's called by the browser-session route.
</Note>

## Purpose

Connects to a Browserbase session via Playwright CDP and navigates to a URL. Runs as a background task so the API response isn't blocked.

## Function Signature

```python theme={null}
async def _navigate_in_background(connect_url: str, url: str, session_id: str)
```

## Parameters

| Parameter     | Type  | Description               |
| ------------- | ----- | ------------------------- |
| `connect_url` | `str` | Browserbase WebSocket URL |
| `url`         | `str` | Target URL to navigate to |
| `session_id`  | `str` | Session ID for logging    |

## What It Does

1. **Connect** - Playwright connects via CDP (Chrome DevTools Protocol)
2. **Navigate** - Go to URL, wait for DOM content loaded
3. **Polish** - Hide scrollbars for cleaner embed
4. **Scroll Animation** - Automated scrolling to simulate "scanning"

## Scroll Animation Sequence

```
[0s]   Page loaded
[2s]   First scroll: 1.5 viewport heights over 1.5s
[8.5s] Second scroll: 1 viewport height over 1.5s
[10s]  Complete
```

## Background Task Pattern

```python theme={null}
# Start task without blocking
task = asyncio.create_task(
    _navigate_in_background(connect_url, body.url, session_id)
)
_NAVIGATION_TASKS[session_id] = task

# Return immediately
return BrowserSessionResponse(session_id=session_id, live_url=live_url)
```

## Code Location

```
src/website/browser_session/routes.py
# Lines 51-112: _navigate_in_background()
```
