Issue with Studio flashing and losing focus while editing content in Nextjs starter.
Not stupid at all - this is a known issue that was actually fixed in a recent Sanity release! The flashing/refreshing behavior you're experiencing with the embedded Studio in Next.js, especially with rich text fields and popup overlays, was a bug that affected production deployments.
Based on a similar case from the community, this was resolved in a Sanity update around March 22, 2024. The issue caused overlays to flash and reload on every background save, which would reset focus and interrupt typing - exactly what you're describing.
The fix: Update your sanity package to the latest version. The fix was in the core sanity package, not next-sanity.
npm update sanity
# or
yarn upgrade sanity
# or
pnpm update sanityAfter updating, redeploy to Vercel and the issue should be resolved.
This issue was particularly noticeable in production but not in local development, which matches your experience perfectly. It affected any fields using popup overlays (arrays, references, portable text editors), causing focus to reset during auto-saves.
If updating doesn't fix it completely, there's one other thing to check with Next.js App Router and embedded Studio: React Strict Mode can sometimes cause components to mount/unmount in development, but Next.js production builds can also have issues with the NextStudio component remounting if your config is being recreated on every render.
If you're using a custom Studio wrapper (like importing a dynamic theme), make sure you're not accidentally triggering re-renders. The boilerplate pattern should be fine, but double-check that your sanity.config.ts isn't doing anything that would cause the config object to be recreated unnecessarily.
The Sanity team has been actively fixing these Studio embedding issues, so keeping your packages updated should prevent similar problems in the future!
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.