How to Configure Windows Sandbox Local Directus Data Platform via XML in Windows 11

Rapid prototyping of relational data architectures, headless CMS schemas, and automated REST/GraphQL APIs often requires an isolated testing environment that can be spun up in seconds and discarded without leaving leftover database services or node packages on the host operating system. Windows Sandbox in Windows 11 Pro and Enterprise provides an ephemeral, hardware-isolated lightweight hypervisor instance ideally suited for this workflow. By pairing Windows Sandbox configuration files (.wsb) with automated PowerShell bootstrap scripts, developers can spin up a fully operational Directus Data Platform backed by SQLite in under two minutes.

Directus wraps SQL databases in real-time GraphQL and REST APIs alongside an intuitive administrative dashboard. Automating its deployment inside Windows Sandbox provides developers with a pristine sandbox environment to test schema migrations, extension hooks, and webhook payloads cleanly.

Windows Sandbox Architecture and Automation Primitives

Windows Sandbox relies on XML configuration files ending in the .wsb extension. These files define hypervisor properties including virtualised networking, mapped host directories, assigned vGPU memory, and logon commands executed immediately upon boot:

  • <Networking>: Controls virtual switch connectivity. Enabled provides outbound internet access to download Node.js packages and container binaries.
  • <MappedFolders>: Mounts host directories into the container filesystem, enabling rapid ingestion of schema snapshots or extension code.
  • <LogonCommand>: Specifies the bootstrap executable or script triggered automatically when the sandbox desktop loads.

Creating the Directus Provisioning Script

Create a dedicated workspace folder on your host machine (such as C:\Sandbox\Directus) and author the setup script named bootstrap-directus.ps1:

# bootstrap-directus.ps1 - Automated Directus Setup for Windows Sandbox
$ErrorActionPreference = "Stop"

Write-Host "Initialising Directus Environment..." -ForegroundColor Cyan

# Install Node.js LTS via winget
Write-Host "Installing Node.js LTS..." -ForegroundColor Yellow
winget install OpenJS.NodeJS.LTS --silent --accept-package-agreements --accept-source-agreements

# Refresh Environment Variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")

# Create project directory
$projectDir = "C:\DirectusApp"
New-Item -ItemType Directory -Path $projectDir -Force
Set-Location $projectDir

# Initialise npm package and install Directus
Write-Host "Installing Directus core..." -ForegroundColor Yellow
npm init -y
npm install directus sqlite3

# Author Directus Environment Configuration
$envContent = @"
KEY=dfa92c73-42e5-4eb8-b99b-e82b7d903912
SECRET=35c10be0-761d-4001-a204-58a436920199
[email protected]
ADMIN_PASSWORD=AdminPassword123!
DB_CLIENT=sqlite3
DB_FILENAME=./data.db
PORT=8055
PUBLIC_URL=http://localhost:8055
CORS_ENABLED=true
"@
$envContent | Out-File -FilePath "$projectDir\.env" -Encoding utf8

# Bootstrap Directus database migrations
Write-Host "Applying database migrations..." -ForegroundColor Yellow
npx directus bootstrap

# Launch Directus in background and launch browser
Write-Host "Launching Directus server..." -ForegroundColor Green
Start-Process "npx" -ArgumentList "directus start" -WindowStyle Minimized

Start-Sleep -Seconds 5
Start-Process "msedge.exe" -ArgumentList "http://localhost:8055"

Authoring the Windows Sandbox Configuration File

In the same folder, create a configuration file named DirectusSandbox.wsb:

<Configuration>
  <VGpu>Enable</VGpu>
  <Networking>Enable</Networking>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\Sandbox\Directus</HostFolder>
      <SandboxFolder>C:\DirectusSetup</SandboxFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:\DirectusSetup\bootstrap-directus.ps1</Command>
  </LogonCommand>
</Configuration>

Running and Testing Directus Inside the Sandbox

  1. Double-click DirectusSandbox.wsb on your Windows 11 host.
  2. Windows Sandbox boots into a clean desktop and automatically launches PowerShell.
  3. The script downloads Node.js, configures SQLite, creates the administrator credentials ([email protected] / AdminPassword123!), and launches the Directus server on port 8055.
  4. Microsoft Edge opens automatically displaying the Directus login portal.
  5. When finished exploring schemas and APIs, close the Sandbox window; all temporary packages, SQLite databases, and cached dependencies are discarded immediately.

This automated workflow provides an ideal development sandbox for testing backend architectures safely without polluting your primary Windows 11 development machine.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.