Startpod
Reference for booting, controlling, and tearing down Startpod.
Import the main class from the package root:
import { Startpod } from "startpod"Startpod.init(options)
Starts one isolated runtime for the current page. No hosting options are needed:
const startpod = await Startpod.init()
startpod.mountPreview(document.querySelector("#preview")!)options.workdirNamestringWorking-directory name. Defaults to proj and produces /proj.
options.basePathstringAsset path for advanced local runtime wiring. The managed runtime does not need this option, even when your application uses a non-root base path.
options.coep'credentialless' | 'require-corp' | 'none'Preview policy. Omission chooses the appropriate supported mode. The host page must be cross-origin isolated.
Properties
| Property | Type | Description |
|---|---|---|
fs | FileSystemAPI | Filesystem rooted at the pod workdir for relative paths. |
path | string | Default executable search path. |
workdir | string | Absolute working-directory path. |
routes | Record<number, string> | Active preview URL by virtual port. |
Project methods
| Method | Returns | Purpose |
|---|---|---|
mount(tree, options?) | Promise<void> | Add a nested FileSystemTree. |
spawn(command, args?, options?) | Promise<StartpodProcess> | Run a supported command. |
spawn(command, options?) | Promise<StartpodProcess> | Run a command with no arguments. |
export(path?, options?) | Promise<FileSystemTree | ProjectArchiveMap | Uint8Array> | Export JSON, binary data, or ZIP. |
importProject(archive, path?) | Promise<void> | Import a prior export. |
saveProject(id, options?) | Promise<boolean> | Save to IndexedDB. |
restoreProject(id, options?) | Promise<boolean> | Restore from IndexedDB. |
teardown() | void | Stop workers, watchers, and preview resources. |
Preview methods
| Method | Purpose |
|---|---|
mountPreview(element) | Render the live project inside the supplied host element. |
unmountPreview() | Remove the managed preview. |
navigatePreview(route) | Navigate a managed preview. |
reloadPreview() | Reload a managed preview. |
setRelayToken(token) | Set or clear the scoped relay capability token. |
capturePreviewScreenshot(timeoutMs?) | Capture a managed cross-origin preview when available. |
requestPreview(request, options?) | Send an HTTP request to the active dev server. |
See Events and errors for on().