Skip to content
This repository was archived by the owner on Aug 20, 2026. It is now read-only.
This repository was archived by the owner on Aug 20, 2026. It is now read-only.

Cloning and running a Vite project snippet #341

Description

@idagelic

Figure out a spot for the following snippet:

import { Daytona } from '@daytonaio/sdk'

const main = async () => {
  const daytona = new Daytona(({
  apiKey: "YOUR_API_KEY",
  }))

  console.log("Creating the sandbox...")
  
  const sandbox = await daytona.create({
    language: 'typescript',
    autoStopInterval: 0
  })
  
  let rootDir = await sandbox.getUserRootDir()

  if (!rootDir) {
    throw new Error("Failed to get user root directory")
  }

  console.log("Cloning the repo ...")

  await sandbox.git.clone(
    "https://github.com/stackblitz/starters",
    rootDir+"/starters",
  )

  // Create a new session and execute a command
  const execSessionId = "app-server"
  await sandbox.process.createSession(execSessionId)

  console.log("Installing and running the app ...")
  
  await sandbox.process.executeSessionCommand(execSessionId, ({
    command: `cd ${rootDir}/starters/bolt-vite-react-ts && npm install && npm run dev -- --host 0.0.0.0`,
    async: true,
  }))

  console.log("Waiting for the app to run ...")

  // Replace this with a poller that checks if the app is available
  await new Promise(resolve => setTimeout(resolve, 10000))

  const previewLink = sandbox.getPreviewLink(5173)
  console.log(`App is available at: ${previewLink}`)
}

main().catch(console.error)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions