Skip to main content

What is a transport?

A transport is a reusable network layer handle that owns:
  1. Transport-level settings like proxy, browser, os, and insecure
  2. Reusable network context used by requests and sessions
Think of it as a “shared network context” you can attach to requests.

When should I use Transport vs Sessions?

Use the simplest tool that matches your needs:

Creating and reusing a transport

A common pattern is one transport per proxy, reused across many requests:

Using Transport with sessions

Sessions are the right default for cookie-based flows. If you want multiple sessions (separate cookies) to share a single transport context (same proxy/emulation), pass the same transport per request:

Ownership rules (important)

When you pass a transport, it owns browser, os, proxy, and insecure.
  • Do not also set browser, os, proxy, or insecure on the request.
  • Prefer creating a separate transport if you need different settings.

Lifecycle

Always close transports you create:
  1. Close when you no longer need the transport: await transport.close()
  2. After closing, the transport cannot be used again
  1. API details: createTransport()
  2. Cookie flows: Sessions