Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

Next, Sanity, Vercel and Typescript templates - Preview functionality

3 replies
Last updated: Jul 11, 2022

Thanks for a great tool, I'm enjoying exploring how it works. I'm stuck with one thing, though: the Next/Sanity/Vercel/Typescript starter appears to have the preview functionality set up, but it doesn't quite follow the different setup tutorials that I've seen elsewhere on the site and I can't get it working. The latest version is hitting a

ClientError: Unauthorized - Session not found
error. I've tried a handful of ways to handle this, including updating to version 2.30 (the starter uses 2.25, which looks like it's before some third party cookie issues were handled). Before going into lots of detail, is there a good place to find the setup for preview as it relates to that starter? (Specifically, I'm talking about this starter: )

Jul 9, 2022, 7:59 PM

For what it's worth, I tried this a few different ways and the latest attempt is giving me a

Not authenticated - preview not available
message. In Firefox, Safari, and Orion I don't get much more. Chrome gives the following trace. I saw an earlier similar message here, but without any responses...

Jul 10, 2022, 2:21 AM


user P
, could you try enabling cross-site tracking in your web browser (and then sign out and back into the Studio)? We think it might be related to cookieless auth and this would confirm it…When cookieless auth is used, next-sanity won’t be able to access previews because the auth token is stored in localStorage instead of a cookie.

Jul 11, 2022, 1:06 PM

Well, check it! It works locally and on Vercel! Is this a known issue that I missed in the docs, then, or a temporary workaround? I appreciate the help and am happy to do whatever to make it more clear for people in the future.

Jul 11, 2022, 6:26 PM Get the most out of your content is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.