Skip to Content
DocsGuidesData for development

Sample data for local development

When you run pnpm dev, the dev server renders your theme with sample data so you can see real content without a store. You provide that data as JavaScript files in the fixtures/ directory, and the dev server wires it into your sections by prop type — no special string syntax needed.

Data-bound props are filled automatically

Any prop declared with a dynamic type — Prop.product(), Prop.collection(), Prop.post() (and the list variants Prop.product[]() etc.) — is filled in development with a matching sample record from fixtures/, chosen by type:

  • Prop.product() → the first record from fixtures/products.js
  • Prop.collection() → the first record from fixtures/collections.js
  • Prop.post() → the first record from fixtures/posts.js

Consider this section:

sections/FeaturedCollection.jsx
import React from 'react'; import {Prop, Link, useProps} from "builderoo"; export default function FeaturedCollection() { const {collection} = useProps() return ( <section className="featured"> <Link to={collection}> <img src={collection.image} /> <h3>{collection.title}</h3> </Link> </section> ); } export const props = { collection: Prop.collection().label("Featured Collection"), }

Create fixtures/collections.js — each fixture needs an _id (the same id your store data carries):

fixtures/collections.js
export default [ { _id: "summer", title: "Summer Vibes", image: "https://picsum.photos/200/320", products: [] }, { _id: "autumn", title: "Autumn Picks", image: "https://picsum.photos/200/320", products: [] }, ]

Now the page just references the section — no data wiring. In dev, collection is filled with the first fixture (summer):

pages/index.json
{ "sections": [ { "component": "FeaturedCollection" } ] }

Choosing a specific record

To show a specific fixture instead of the first, add a fixture:props block to the section, keyed by the prop name, referencing the fixture’s _id:

pages/index.json
{ "sections": [ { "component": "FeaturedCollection", "fixture:props": { "collection": "autumn" } } ] }

For list props (Prop.collection[]() etc.), fixture:props accepts an array of ids or a count:

{ "component": "CollectionRow", "fixture:props": { "collections": ["summer", "autumn"] } } { "component": "CollectionRow", "fixture:props": { "collections": 3 } }
fixture:props valueResult
(omitted)First fixture of the prop’s type
"autumn"The fixture whose _id is autumn
["summer", "autumn"]Those fixtures, in order (list props)
3The first 3 fixtures (list props)

Model pages

A model page (product, collection, …) declares its sample record with a top-level fixture:props block, keyed by the model name:

pages/product.json
{ "fixture:props": { "product": "carmel-brown" }, "layout": { "component": "MainLayout" }, "sections": [ { "component": "Product" } ] }

The value follows the same rules — omit it for the first record, use an _id for a specific one, and list keys like collections accept an array of ids or a count (or nothing, for all).

fixture:props is development-only

fixture:props blocks never reach production. When the platform compiles your theme they are stripped from the templates — in a live store these props are bound to the merchant’s real data through the theme editor. So fixture:props is purely your local preview; it doesn’t affect the shipped theme.

Special data files

A few fixtures/ files feed shop-wide sample state (not tied to a prop):

fixtures/menu.js

fixtures/menu.js
export default { main: [{title: "Products", url: "/products"}, {title: "Collections", url: "/collections"}], footer: [{title: "Products", url: "/products"}, {title: "Collections", url: "/collections"}] }

fixtures/user.js

The sample customer for local development. Dev starts logged out (useUser() returns null, like a fresh visitor); visiting /account/login shows a dev-login button that signs in as this fixture, and /account/logout signs out again — so you can preview both states of your theme.

fixtures/user.js
export default { _id: "1", firstName: "John", lastName: "Doe", email: "test@example.com" }

fixtures/cart.js

The dev server also exposes an in-memory /api/cart seeded from this fixture, so add-to-cart, quantity steppers and remove buttons work for real during development (same request/response shape as production). The cart state resets when the dev server restarts.

fixtures/cart.js
import products from "./products"; export default { items: products.map(p => ({ product: p, quantity: 1, variant: p.variants[0] })) }

Earlier themes referenced fixtures with a string, e.g. "collection": "data:collections:0", and model pages used "dev:data": "data:products:0". That positional syntax is replaced by the type-driven approach above: drop the data: string (the prop fills by type automatically) and, when you need a specific record, add a fixture:props block referencing the fixture’s _id.

- { "component": "FeaturedCollection", "props": { "collection": "data:collections:1" } } + { "component": "FeaturedCollection", "fixture:props": { "collection": "autumn" } }

The block was also briefly named dev:props — if your theme uses that spelling, rename it to fixture:props (the compiler still strips the old key from production builds, but the dev server no longer reads it).