# Configure TrueProxies with Puppeteer

> Configure TrueProxies with Puppeteer using HTTP authentication or SOCKS5 trusted IPs, with examples for Residential IPv4 country targeting and sticky sessions.

Source: https://docs.trueproxies.com/integrations/puppeteer/

> **Use your own endpoints**
>
> The examples below use placeholders. Copy the connection host, ports, username, and proxy password from the **Username and password** tab of your service in the dashboard. See [How to connect](https://docs.trueproxies.com/proxy-instructions/how-to-connect/#connection-host-and-ports).

## Basic usage

**HTTP**

```javascript
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
  args: ['--proxy-server=http://YOUR_HOST:YOUR_HTTP_PORT'],
});

const page = await browser.newPage();

await page.authenticate({
  username: 'your_username',
  password: 'your_password',
});

await page.goto('https://httpbin.org/ip');
const content = await page.content();
console.log(content);

await browser.close();
```

**SOCKS5**

Chrome does not send a username and password to a SOCKS5 proxy, and `page.authenticate` only answers HTTP proxy challenges. To use SOCKS5, add the machine’s public address as a [trusted IP](https://docs.trueproxies.com/proxy-instructions/trusted-ips/) and connect without credentials. For username and password authentication, use the HTTP tab.

```javascript
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
  args: ['--proxy-server=socks5://YOUR_HOST:YOUR_SOCKS_PORT'],
});

const page = await browser.newPage();

await page.goto('https://httpbin.org/ip');
const content = await page.content();
console.log(content);

await browser.close();
```

## Residential IPv4 country targeting

```javascript
await page.authenticate({
  username: 'your_username-country-us',
  password: 'your_password',
});
```

## Residential IPv4 sticky sessions

```javascript
await page.authenticate({
  username: 'your_username-session-abc123',
  password: 'your_password',
});
```

## Multiple pages with different IPs

```javascript
const browser = await puppeteer.launch({
  args: ['--proxy-server=http://YOUR_HOST:YOUR_HTTP_PORT'],
});

const urls = ['https://example.com', 'https://example.org'];

for (const url of urls) {
  const page = await browser.newPage();
  await page.authenticate({
    username: 'your_username',
    password: 'your_password',
  });
  await page.goto(url);
  console.log(`${url}: loaded`);
  await page.close();
}

await browser.close();
```

## Related guides

- [Connection and username format](https://docs.trueproxies.com/proxy-instructions/how-to-connect/)
- [HTTP CONNECT and SOCKS5](https://docs.trueproxies.com/proxy-instructions/proxy-protocols/)
- [Trusted IPs](https://docs.trueproxies.com/proxy-instructions/trusted-ips/)
- [Troubleshooting checklist](https://docs.trueproxies.com/support/)
