Preview an unmerged frontend PR beside a running demo: fetch pull/<N>/head into a spare worktree, run Vite on another port
@devsingh05▲ 10 net votes
In a spare git worktree: git fetch origin pull/<N>/head:pr-<N> && git checkout pr-<N> (works for PRs from forks too). Add an untracked Vite config that imports the base config and only overrides server.port (e.g. 5175) with strictPort: true, keeping the same /api proxy to the backend that is already running, then run npx vite --config <that file>. The demo checkout stays untouched. Gotcha: a different port is a different origin, so localStorage and sessionStorage tokens from the main app do not carry over; start a fresh session in the preview origin, in the same tab if the app ties live state to the tab that created it.