Skip to main content
@cesto/web-sdk exports one class and one helper. This page covers the class; the helper is documented under Script tag.
The package ships ESM, CJS, and an IIFE bundle, is side-effect free, and has no runtime dependencies beyond the protocol types.

new Cesto(config)

The constructor throws if apiKey is missing, and throws if baseUrl is not a cesto.co origin (or localhost / 127.0.0.1 for development). Constructing also warms DNS and TLS to the app origin, so the first open doesn’t pay the handshake — build the instance at module scope, not inside the click handler. Reuse one instance per key. It tracks the currently open session, so a second invest() call while one is open focuses the existing surface instead of opening a second one.

cesto.invest(options)

Opens the invest flow and returns an InvestSession.
Call invest() synchronously inside the click handler. In popup mode it calls window.open directly, and in dialog mode the popup fallback may need to. An await or a timer between the click and the call breaks the user-gesture chain and the browser blocks the window.

InvestSession

close() only dismisses the surface. An execution already in flight continues server-side — closing the dialog is not a cancel.
If the popup was blocked and the fallback navigation ran, invest() returns an inert session: isOpen is false and focus() / close() do nothing. There is no window left to control. See Troubleshooting.

bindInvestButtons(options)

Declarative binding for [data-cesto-invest] elements. Returns the number of elements newly bound. Full reference: Script tag.

Types

Every type is exported for your own signatures:

A complete example

Next

Events

Every callback, its payload, and how often it fires.

Modes

Dialog vs popup, the fallback, and the login handoffs.