Following the Sanity A/B testing tutorial, preview link shows default content
I worked through the Sanity A/B testing and personalization tutorial step by step. Everything works: the slot serves content, the experiment is running, production traffic splits correctly.
The one thing that does not work is preview links. I generate a link from the experiment editor, open it, and the page shows the default content instead of the variant. No error anywhere, just the default.
Steps I took: created the experiment with two variants, published it, generated the preview link, opened it in the same browser and in incognito. Same result both times. Our domain is already added in the dashboard. What am I missing
2 answers
Given that production traffic splits correctly and the domain is trusted, the most likely cause is a slot version mismatch. Preview links require the slot version referenced in your code to match the version of the content being previewed. When they differ, the page renders the default content with no error, exactly as you describe.
This typically happens when the slot ID in code has no version pinned. An unpinned ID like home-hero resolves to @latest, and if the slot schema was updated after you integrated it, your code and the previewed content can drift apart. Pin the version explicitly:
const {content} = await fetchContent('home-hero@2', { fallback: defaultContent,});To verify, check the slot's current version in the dashboard and compare it with what your code requests. Pinning also protects production: without it, a published schema change takes effect immediately and can break the app.
The points from the previous answer apply as well: links are valid for 24 hours and can be regenerated at any time, and the exact origin must be in the trusted origins list. But with your symptoms, check the version first.
Two quick things to rule out since you said the domain is set up: the links expire after 24 hours, so if you generated it yesterday it will silently fall back to default content. Regenerate a fresh one from the editor.
Also double check you are opening it on the exact origin listed in trusted origins. Preview on www.example.com fails if only example.com is trusted. Bit me once with a staging subdomain.