Skip to Content

List your previews with the SDK

Both are server tools: they need no machine to be selected, and work with SDK 3.9.1 or later. The token needs the http permission, which the owner turns on as “Open your previews” for the agent; without it the call is refused with denied. To offer an app as a preview in the first place, see previews.

const previews = await client.previews_list({}); for (const p of previews) { console.log(p.name, p.port, p.machine.name, p.visibility, p.signed_in); }
for p in client.previews_list(): print(p.name, p.port, p.machine.name, p.visibility, p.signed_in)

p.url is the preview’s address. Share links are listed with their note, expiry and state, never their address.

Open a private preview

preview_open takes the preview’s name and returns url and expires. The link signs the browser that opens it in to that preview as you; it works up to 3 times within 10 minutes. Treat it as a secret: open it, do not print, log or send it. A public preview returns its own address with no expires.

import webbrowser link = client.preview_open(name="storybook") webbrowser.open(link.url)

Runnable source

The pair is previews in the source catalog. It is not run by default; select it with a token that has http:

ONLY=previews bash examples/run.sh

SDK examples · Previews