Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Preview in Next.js makes Everything Slow with Timeouts

8 replies
Last updated: Jun 14, 2022
Hi! Preview in NextJs makes everything slowAnyone else struggling with big lags and timeouts when using the preview function? Happens when I use the preview button in the Studio and using the preview link to the site. Happens in both locally and production environment. If I wait long enough I get a "Page unresponsive" error from the browser
Only way to make it disappear is deleting the preview-cookie (and therefore not being in preview anymore)

Using the "NextJs with comments"-starter setup
Jun 14, 2022, 12:39 PM
Do you have a link to the starter please? Looks like a query that keeps running permanently or something.
Jun 14, 2022, 12:40 PM
Sorry. It was this one: https://github.com/sanity-io/next-sanityThough (I wasn't the initial dev to set it up), so not complete sure if there's any major differences
Jun 14, 2022, 12:48 PM
Jun 14, 2022, 12:54 PM
I‘m thinking
usePreviewSubscription
runs too aggressively.
Jun 14, 2022, 1:32 PM
OkI'll look into it! Thanks!

I was looking at what loads and maybe that would help me out
On a page load when preview is active the page doesn't respond to anything until theese two loads:
Jun 14, 2022, 1:44 PM
Looks like updating the "next-sanity" package from 0.4.0 to the newest (0.5.2 at this point) fixed the issue :)
Jun 14, 2022, 2:34 PM
Nice!
Jun 14, 2022, 2:51 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?