surfsky package uses ES modules and includes TypeScript definitions.
SURFSKY_API_TOKEN and SURFSKY_API_BASE_URL from the dashboard. See credential setup. You can also pass apiToken and baseUrl to the constructor.
Start a browser
Save asfirst-browser.mjs and run node first-browser.mjs. The same code can be used in a TypeScript project configured for ESM.
Example Domain. browser.close() stops the session. Put it in finally so it also runs when a page operation throws. Cleanup cannot complete if the process is forcibly terminated or loses access to the API.
On runtimes that support explicit resource management, such as Node.js 24+ or Bun, await using can handle cleanup at scope exit:
try/finally or a TypeScript build that transforms await using for your runtime.
Interact with the page
Methods includegoto, click, type, hover, innerText, and waitForSelector. Run page operations while the browser is open, using selectors from your target page:
evaluate() runs JavaScript in an isolated execution context by default. Use isolated: false to access variables defined by the page. DOM changes remain visible to the page.
Save traffic
Choose resource types when starting a browser:Capture a page’s API response
Start capture before navigation. Adapt the URL and response path to your application:Multiple tabs
browser operates on the first tab. browser.pages contains other tabs and popups:
Running many browsers
Proxies
Passproxy to browser() or session():
tier: "shared" or supply a proxy URL. Close the browser after use. client.proxies provides location and quota lookups; see Proxies.
Profiles
profile.uuid and start that profile on later runs. See Sessions for login persistence.
Raw requests
request() returns the raw response and does not throw on HTTP status. The SDK repository contains the complete method reference and examples.