Use case
You have one Next.js repo and run npm run dev directly. You want multiple Spaces workspaces active at once, each with its own service and browser tab.
Use this when your frontend runs directly on your machine, no containers, and you want multiple workspaces with isolated services and stable URLs.
You have one Next.js repo and run npm run dev directly. You want multiple Spaces workspaces active at once, each with its own service and browser tab.
frontendDeclaring a named service gives each workspace its own local port and a stable URL, so two branches can both run a dev server without colliding.
npm i
cp .env.example .envnpm i makes sure dependencies are present in every workspace. cp gives each workspace its own .env copy, so branch-local env edits do not leak between workspaces; a symlink would keep one source of truth but couple every workspace's env together. Swap .env.example for whatever seed file your repo keeps, Spaces has no built-in shared env file.
PORT=$SPACES_FRONTEND_PORT npm run devThis binds Next.js to the service's assigned local port, so each browser session opens the right workspace's instance.
$SPACES_FRONTEND_URLPoint a browser session at the named service so each workspace opens its own app tab reliably. $SPACES_FRONTEND_URL resolves to http://frontend.<slug>.localhost:7391. Chrome treats *.localhost as a secure address, so this works over plain HTTP with no certificate.