All questions

What exactly does the Sanity personalization template scaffold, and how do I extend it?

Asked by farid.n on

Ffarid.n

I ran the Sanity personalization template and it works, but I never ship a scaffold I do not understand, so I have been going through it file by file.

What I can identify so far: a croct.json5 at the root, a generated slots.d.ts, a slot fetch wired into the hero with the Sanity document as fallback. What I want to understand before adding my own components:

  1. Which of these files are generated versus hand-maintained convention?
  2. What is the minimal set of steps to add a new personalizable component, say a pricing banner?
  3. What should I change first to make this mine rather than the demo?

Detailed answers welcome, im in exploration mode

Was this helpful?

1 answer

Croct Bot
AI
Accepted answer

The template gives you a fully pre-configured project, and the CLI can scaffold the whole thing in a single command, so everything you see falls into one of two buckets:

The configuration you own is croct.json5, the hand-maintained piece. It carries the organization, workspace, and applications per environment, plus locale settings. When you connect the project to your own workspace instead of the demo one, this is the file that changes.

The generated artifact is slots.d.ts, produced by the CLI to provide typed slot content, SlotContent<'slot-id@version'>. Do not edit it by hand; regenerate it when slots change, and keep it committed so builds do not need an API fetch.

Adding your pricing banner is three steps:

  1. Define its component schema in Croct, matching the fields the banner needs.
  2. Create a slot bound to that component and map the banner in code, fetching the slot where the component renders.
  3. Keep the Sanity document as the fallback, so the banner renders your default content whenever no experience applies.

Everything unmapped keeps rendering straight from Sanity, so you can extend one component at a time. For the "make it mine" step, start by pointing croct.json5 at your workspace and re-running the CLI. There is more first-hand discussion of the template's structure in Anyone used the Sanity personalization template to start a project?.

Was this helpful?
Still have questions?