Our Sanity frontend is plain JS, not Next. Can I still use the integration?
Our Sanity site is a hand-rolled vanilla JS frontend, no Next, no React, nothing. Most examples I find assume a framework and a provider component, so I cannot tell if that is a hard requirement or just the happy path.
Can I still wire up the personalization layer on a plain JS site, or is a framework doing something I would have to reimplement myself
2 answers
No framework required. The JavaScript SDK @croct/plug works standalone on any frontend. You initialize it once and then fetch slot content directly:
import croct from '@croct/plug';
croct.plug({appId: 'YOUR_APPLICATION_ID'});
const {content} = await croct .fetch('home-hero@1') .catch(() => ({content: {title: 'Default headline'}}));The .catch handler is your fallback for a timeout or network hiccup. And because your existing Sanity content is already the default fallback on the slot itself, an ordinary visitor gets the normal content regardless of the framework question.
Worth knowing for later: if you ever move this onto a framework there are dedicated SDKs for React, Next.js, Vue and Nuxt that give you providers and hooks instead of the manual fetch. Same backend, nicer ergonomics. But for a vanilla JS site the plain package stefan showed is exactly right and you lose nothing by staying on it.
good to know, staying vanilla for now but nice that the path exists. got the fetch working, thanks