Guide: Next.js + Django (Separate Repos)

Use this when frontend and backend live in different projects but you want one active workspace context for both.

Use Case

Frontend and backend are separate repos. You want one workspace to run both processes and keep browser sessions aligned.

Project Settings

The frontend workspace must own both frontend and backend services and run both processes if it is the central context for both services.

Frontend Project Template

Services: frontend, backend
Frontend Server: API_URL=$SPACES_BACKEND_URL PORT=$SPACES_FRONTEND_PORT npm run dev
Backend Server: cd /path/to/backend-project && python manage.py runserver 0.0.0.0:$SPACES_BACKEND_PORT
Browser Session: $SPACES_FRONTEND_URL

The backend server is started from the frontend workspace so both processes can receive the same SPACES_<SERVICE>_PORT and SPACES_<SERVICE>_URL env vars Spaces injects for each service. The backend row can change directories directly because process commands run as shell input.

← Back to Cookbook Guides