StartpodDocs

Work with files and projects

Mount a project, read and write files, and import or export a complete workspace.

Each pod has an in-memory filesystem. The default working directory is /proj; set workdirName during boot to change it.

Mount a project

mount() accepts a nested FileSystemTree. Paths are relative to the working directory.

await startpod.mount({
  src: {
    directory: {
      "main.js": {
        file: { contents: 'console.log("Hello")' },
      },
    },
  },
  "empty-directory": { directory: {} },
})

File contents can be a UTF-8 string or a Uint8Array. Symlinks use { file: { symlink: './target' } }.

Use the filesystem API

await startpod.fs.mkdir("src/components", { recursive: true })
await startpod.fs.writeFile("src/config.json", '{"theme":"dark"}')

const text = await startpod.fs.readFile("src/config.json", "utf8")
const entries = await startpod.fs.readdir("src", { withFileTypes: true })

Filesystem calls accept relative or absolute paths. Relative paths resolve against startpod.workdir and are usually the safest choice. When you need an absolute path, derive it from startpod.workdir instead of hard-coding /proj.

Export and import

Export a project as a nested tree, flat binary map, or ZIP archive:

const zip = await startpod.export(".", { format: "zip" })
const tree = await startpod.export(".", { format: "json" })

node_modules is excluded by default. Import the result later with importProject():

await startpod.importProject(zip)

Use project persistence when you want automatic local saves instead of a download or upload flow.

On this page