Before you start
Nefo offers residential proxies in 227 countries over HTTP, HTTPS, and SOCKS5 with username/password auth. Generate credentials in the dashboard proxy generator; that step is free and only routed traffic uses your prepaid bandwidth (from 5 GB for $4.50, non-expiring on flexible plans).
Playwright accepts proxy credentials directly in the launch options, so no separate authentication event handler is needed.
- Node.js 18+ with @playwright/test or playwright installed
- Browsers installed via npx playwright install
- A Nefo account with prepaid bandwidth
- A username/password from /dashboard/generator
- The country token for your target region
Playwright proxy example
Set the proxy on the launch call:
You can also scope proxies per context with browser.newContext({ proxy: {...} }), which lets one browser run several geo profiles side by side just by changing the username token.
import { chromium } from 'playwright';
const browser = await chromium.launch({
proxy: {
server: 'http://gw.nefo.net:9000',
username: 'USERNAME-country-us',
password: 'PASSWORD',
},
});
const page = await browser.newPage();
await page.goto('https://api.ipify.org');Playwright rotating vs sticky proxy sessions
Rotating sessions give a new residential IP per request on HTTP port 9000, ideal for high-volume, distributed crawling.
Sticky sessions pin one IP from 1 minute to 24 hours on HTTP port 10000. Use a token like USERNAME-country-us-session-shop1-lifetime-60 to keep the same IP for a 60-minute session. Playwright supports authenticated HTTP proxies, so prefer the HTTP ports when you need username/password auth.
Geo-targeting in the Playwright proxy username
Targeting lives in the username: country for 227 countries, US state and city, or ASN/ISP within a country. Change only the username to move exits between regions without touching your code paths.
Collect data responsibly, honor site terms of service, and respect applicable laws and reasonable request rates.
Frequently asked questions
Yes. Pass a proxy object to browser.newContext() and change the username token per context. One browser can then run several countries or sticky sessions side by side.
Use HTTP port 9000 (rotating) or 10000 (sticky). Authenticated SOCKS5 is not reliable in Chromium, so the HTTP ports are recommended when you use username and password auth.
Use port 10000 and add a session and lifetime token, for example USERNAME-country-us-session-abc-lifetime-30, to hold the IP for up to 24 hours. Create the context once and reuse it for the flow.
Append the country token to the username, such as USERNAME-country-de for Germany. US state, city and ASN targeting use further tokens in the same username.
Credentials do not expire and are free to generate. On flexible prepaid plans your bandwidth balance does not expire either; only traffic uses it.