@freestyle-sh/with-vscode
v0.0.3
Published
[VS Code](https://github.com/coder/code-server) in the browser for [Freestyle](https://freestyle.sh) VMs, powered by code-server.
Downloads
362
Readme
@freestyle-sh/with-vscode
VS Code in the browser for Freestyle VMs, powered by code-server.
Installation
npm install @freestyle-sh/with-vscode freestyleUsage
import { freestyle, VmSpec } from "freestyle";
import { VmVscode } from "@freestyle-sh/with-vscode";
const domain = `${crypto.randomUUID()}.style.dev`;
const { vm } = await freestyle.vms.create({
snapshot: new VmSpec({
with: {
vscode: new VmVscode(),
},
}),
domains: [
{
domain,
vmPort: 8080,
},
],
});
console.log(`VS Code available at: https://${domain}`);With Extensions
const { vm } = await freestyle.vms.create({
snapshot: new VmSpec({
with: {
vscode: new VmVscode({
workdir: "/root/project",
extensions: ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"],
}),
},
}),
domains: [
{
domain,
vmPort: 8080,
},
],
});Options
new VmVscode({
port: 8080, // Optional: port to run on (default: 8080)
workdir: "/root", // Optional: folder to open (default: /root)
user: "root", // Optional: user to run as (default: root)
extensions: [], // Optional: VS Code extensions to pre-install
})| Option | Type | Default | Description |
|--------|------|---------|-------------|
| port | number | 8080 | Port to run code-server on |
| workdir | string | "/root" | Folder to open in VS Code |
| user | string | "root" | User to run code-server as |
| extensions | string[] | [] | VS Code extensions to pre-install (e.g. ["esbenp.prettier-vscode"]) |
API
vm.vscode.route({ domain })
Expose code-server publicly via Freestyle domain routing.
await vm.vscode.route({ domain: "my-editor.example.com" });vm.vscode.port
Returns the configured port number.
How It Works
The package uses systemd services to install and run code-server during VM creation:
- Downloads code-server v4.100.3 from GitHub releases
- Installs any specified VS Code extensions
- Starts code-server as a systemd service with auto-restart
Authentication is disabled by default. Code-server listens on all interfaces (0.0.0.0).
