Examples
Example-driven guides for building Custom Blocks with the Tapcart CLI.
This section contains end-to-end examples of Custom Blocks.
Each example includes:
- A complete
code.jsx - A complete
manifest.json - Notes on what to customize
Examples
- Navigate to a screen/tab using
openScreen - Destination picker navigation (manifest destination + openScreen)
- Banner with CTA destination (asset upload + destination)
- Countdown timer (date-time + optional destination)
- Accordion (flex-list)
- Add to cart button (PDP)
- Add to cart with personalization (mockData.json)
- Goal progress bar (mockData.json)
- Collection bar (data hooks + loading/empty states)
- Collections menu with subcollections (flex-list + destinations + drawer)
Mock Data (optional)
When developing locally, you can add a mockData.json file next to code.jsx in a block folder.
This is read by the local dev server and makes data available via useVariables().
{
"customer": {
"id": "<UUID>",
"firstName": "Taylor"
},
"device": {
"locale": "en-US"
},
"cart": {
"items": []
}
}Notes:
mockData.jsonhelps when your block usesuseVariables().mockData.jsondoes not mock network-backed hooks (for example,useCollection). Those hooks fetch from Tapcart APIs.
Learn more:
Updated 24 days ago