Use Case
You have one Next.js repo and run npm run dev directly. You want multiple Spaces workspaces active at once, each with isolated services and browser tabs.
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 isolated services and browser tabs.
frontendDeclare a named service per workspace. Spaces assigns each service its own local port and a stable URL, so two branches can both run a dev server without collisions.
npm i
cp .env.example .envnpm i ensures dependencies are present in new workspaces.cp creates an independent .env copy per workspace. Copy is safer when you want branch-local env edits. A symlink keeps one source of truth, but changes affect all workspaces and can cause surprising cross-branch coupling. Swap .env.example for any real path you maintain — Spaces does not provide a built-in shared env file.
PORT=$SPACES_FRONTEND_PORT npm run devThis binds Next.js to the service's assigned local port, so browser sessions target the correct workspace instance.
$SPACES_FRONTEND_URLBrowser session URLs should use named services so each workspace opens its own app tab reliably. $SPACES_FRONTEND_URL resolves to http://frontend.<slug>.localhost:7391, routed by the bundled Caddy proxy. Chrome treats *.localhost as a secure context, so this works over plain HTTP without certificates.