How to Run a Node Project in CodeSandbox Devboxes

October 30, 2026

A CodeSandbox Devbox is a cloud virtual machine — root access, a terminal, full Node and Docker — attached to a VS Code editor in your browser. Import a GitHub repo and it boots a working environment in about 60 seconds.

The distinction from the old CodeSandbox sandboxes matters: Devboxes can run a database, spawn background processes and install anything from apt. Sandboxes cannot.

What is the difference between a sandbox and a devbox?

A sandbox is a browser container for single-page examples. It has no shell, no persistence, and a limited filesystem.

A devbox is a VM with 2-16 vCPU, persistent disk, and SSH. It survives reloads, sleeps after inactivity, and can be resumed from the dashboard. The free tier gives you a few devbox hours, and they are consumed fast if you leave builds running.

How do you import a repo?

  1. Log in at codesandbox.io with GitHub.
  2. Click Import repository, choose the repo and branch.
  3. Pick a template: Node.js, Next.js, or Docker if you want your own image.
  4. Wait for npm install — CodeSandbox auto-runs it when it detects a package.json.
  5. The preview pane opens whatever port it detects first; use the Ports tab if it guesses wrong.

Paste a GitHub URL into the dashboard search bar and it skips the import dialog — the fastest path if you already know the repo.

What does a devbox config actually control?

The .codesandbox/tasks.json file. It defines tasks, which are command plus a port plus a “run at start” flag:

{
  "setupTasks": [
    { "name": "install", "command": "npm install" }
  ],
  "tasks": {
    "dev": { "command": "npm run dev", "runAtStart": true },
    "test": { "command": "npm test", "restartOn": { "file": "**/*.test.ts" } }
  }
}

setupTasks run once when the devbox is created. tasks can be triggered manually from the sidebar, and restartOn gives you a watch-and-rerun without writing nodemon configs.

Is CodeSandbox free?

There is a free tier aimed at individuals: a limited number of devbox hours per month, 2 vCPU base, and public sandboxes. It is enough for trying things and not enough for a working day.

Paid plans are per-seat and start around $9-18/month depending on credits included. VM sizes above 4 vCPU consume credits faster; the billing page lists the multiplier per class.

Compare honestly against alternatives: GitHub Codespaces gives 120 core-hours free per month, which is more generous for small repos, and Gitpod sells the same cloud-IDE idea with prebuilds attached. CodeSandbox‘s edge is that preview URLs are shareable with a click and the browser editor is snappier than VS Code Web on heavy repos.

Where does the preview URL come from?

Every exposed port gets its own public HTTPS subdomain, like abc123-5173.csb.app. Anyone with the URL can open it — there is no auth by default.

That is a real risk. A devbox running your app against a staging database with real user data is now publicly reachable. Set a port to private in the Ports tab when the preview touches anything sensitive.

The URL also changes when the devbox is recreated, so never put a csb.app link in documentation.

When CodeSandbox loses

  • Heavy full-stack work. A Docker compose stack with three services gets slow and credit-hungry above 4 vCPU.
  • Anything needing a GPU. No GPU devboxes on the consumer tiers.
  • Team code review. You can share a devbox, but branch-per-PR environments are more natural in Gitpod or Render previews.

It is best at the thing it started as: zero-setup environments for tutorials, bug reproductions and “can you look at this” links.

Key Takeaways

  • Devboxes are real VMs with a terminal and root; sandboxes are not.
  • .codesandbox/tasks.json defines setup tasks, run tasks and file-watch rerun rules.
  • Preview URLs are public by default — mark sensitive ports private.
  • Free devbox hours are limited; Codespaces offers 120 free core-hours monthly by comparison.
  • Suits tutorials, bug repros and quick demos; poor for GPU work and large multi-service stacks.