Skip to main content

playwriter session new

Create a new session and print the session ID. A session is required to execute code with the -e flag.
playwriter session new
playwriter session new --browser <stableKey>
playwriter session new --host example.com

Options

--host
string
Remote relay server host to connect to (or use PLAYWRITER_HOST env var)
--browser
string
Stable browser key when multiple browsers are connected. Use this to select which browser to create the session for.

Returns

Prints the session ID to stdout:
Session 1 created. Use with: playwriter -s 1 -e "..."

Exit Codes

  • 0 - Session created successfully
  • 1 - No connected browsers detected or invalid browser key specified

Examples

playwriter session new

playwriter session list

List all active sessions with their metadata.
playwriter session list
playwriter session list --host example.com

Options

--host
string
Remote relay server host to connect to (or use PLAYWRITER_HOST env var)

Returns

Prints a table with session details:
ID  BROWSER  PROFILE           EXT           STATE KEYS
--  -------  -------           ---           ----------
1   Chrome   [email protected]  abc123def456  page, dialog
2   Chrome   -                 -             -
If no sessions exist:
No active sessions

Exit Codes

  • 0 - Successfully listed sessions
  • 1 - Error connecting to relay server

Examples

playwriter session list

playwriter session delete

Delete a session and clear its state.
playwriter session delete <sessionId>

Arguments

sessionId
string
required
The ID of the session to delete

Options

--host
string
Remote relay server host to connect to (or use PLAYWRITER_HOST env var)

Returns

Session 1 deleted.

Exit Codes

  • 0 - Session deleted successfully
  • 1 - Session not found or error during deletion

Examples

playwriter session delete 1

playwriter session reset

Reset the browser connection for a session. This reconnects to the browser and reports available pages.
playwriter session reset <sessionId>

Arguments

sessionId
string
required
The ID of the session to reset

Options

--host
string
Remote relay server host to connect to (or use PLAYWRITER_HOST env var)

Returns

Connection reset successfully. 3 page(s) available. Current page URL: https://example.com

Exit Codes

  • 0 - Connection reset successfully
  • 1 - Session not found or error during reset

Examples

playwriter session reset 1

Build docs developers (and LLMs) love