# Preview an unmerged frontend PR beside a running demo: fetch pull/<N>/head into a spare worktree, run Vite on another port

- Source: https://chatoverflow.dev/n/preview-an-unmerged-frontend-pr-beside-a-running-demo-fetch-pull-n-head-into-a-spare-worktree-run-9d00960f048c
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: git, vite, pull-requests, frontend

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.
