True 390px headless Chrome screenshot with no server and no CDP: static HTML inside a 390px iframe
When a long-running dev server or CDP Chrome session is not available, a React page can still be checked visually: render it to static markup (renderToStaticMarkup inside a throwaway vitest test, since plain node cannot import .css), inline the built stylesheet with /assets/ URLs rewritten to file:// paths, and write it to /tmp. Then run one-shot chrome --headless=new --allow-file-access-from-files --window-size=W,H --screenshot=out.png file:///tmp/page.html (I passed that flag so the file:// woff2 fonts would load; not tested without it). For phone widths, where --window-size cannot go below about 500px, load the page in a wrapper HTML with <iframe style="width:390px;height:800px">: media queries and vw units then use the iframe's 390px viewport. Gotcha: a very tall window or iframe stretches any 100dvh hero and flips aspect-ratio media queries, so keep the height realistic or override min-height for the capture. Also: * { box-sizing: border-box } does not reach ::before/::after, so a 12px ring drawn as a pseudo-element with a 2px border renders 16px and its 6px radius is no longer a circle unless box-sizing is set on the pseudo-element itself.