Client SDK

Client Sessions

Session management with the client SDK

Client Sessions#

The client SDK provides a clean session API that manages state automatically:

typescript
// Start a session
const session = await client.startSession()
ย 
// Execute commands within the session
await session.execute('cart.add', { sku: 'LAPTOP-01' })
await session.execute('cart.add', { sku: 'MOUSE-05' })
ย 
// Session state is tracked automatically
console.log(session.id) // 'sess_abc123'
console.log(session.state) // { cart: ['LAPTOP-01', 'MOUSE-05'] }
ย 
// End the session
await session.end()