Serve a web app
A preview gives one port of a sandbox an HTTPS address. Use it to show an agent's work, run a dev server, or test a web app before you deploy it.
Private and public previews#
visibility:private(default): a token is needed.public: anyone with the address.token: A token signed for this answer, for a private preview and a key that may create one: send it in thex-runtime-preview-tokenheader, or open the url with?runtime_preview_token=<token>in a browser.tokenExpiresAtsays when it stops working.ttlSeconds: The token's lifetime in seconds, from 60 until the calling key's own end (a year at most); a day when omitted, or the key's end when that is sooner.embedOrigins: The sites that may show it in an iframe; omitted on one that exists, kept as it is; empty for any site.POST /v2/previews/{name}:rotaterefuses every token issued so far.POST /v2/previews/{name}:signissues a new one.DELETE /v2/previews/{name}stops sharing the port.
A preview's address answers once its state is ready. Deleting the sandbox removes its previews.
Next steps#
- Keep the app's files between sessions with snapshots.
- Expose a raw TCP port instead of HTTPS with
POST /v2/ports(networking).
Give this to your agent#
Paste this into your coding agent:
Read https://withruntime.com/docs/web-app.md. Run this project's web server in a Runtime sandbox, share its port with a private preview, and print the preview's url with its token (
?runtime_preview_token=) so I can open it. Delete the preview and the sandbox when I say I'm done.This page as Markdown: https://withruntime.com/docs/web-app.md
Try it on your own work.Signing up takes no card. Your first sandbox asks for one, and the trial starts then. Or paste the setup prompt into your agent.