StartpodDocs

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.workdirNamestring

Working-directory name. Defaults to proj and produces /proj.

options.basePathstring

Asset 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

PropertyTypeDescription
fsFileSystemAPIFilesystem rooted at the pod workdir for relative paths.
pathstringDefault executable search path.
workdirstringAbsolute working-directory path.
routesRecord<number, string>Active preview URL by virtual port.

Project methods

MethodReturnsPurpose
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()voidStop workers, watchers, and preview resources.

Preview methods

MethodPurpose
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().

On this page