Context Data Source
8 min
overview the context data source re exposes data that already exists in $context as a list, making it available to list components (swiper, list, dropdown, etc ) it performs no api call — it simply reads a value already in context and passes it through the data source pipeline, enabling features like limit , offset , randomize , and child component binding to work on context data when to use this use context when data is already loaded into $context by a parent component or another data source, and you need to iterate over it in a list component this avoids redundant api calls and is the right pattern for passing nested arrays (e g , the images array on an article) into a swiper or list basic example { "type" "context", "contextkey" "galleryimages", "contextpath" "article images" } this reads $context article images (already in context) and re exposes the array as $context galleryimages a swiper component can then iterate over $context galleryimages to render each image configuration type specific properties property type default description contextpath string — required dot notation path into $context where the source array lives (e g article images , publication authors ) common configuration (inherited) all common data source properties apply — contextkey , limit , offset , randomize , etc batchsize , maxcacheage , and preventssrcache have no meaningful effect since no api call is made for more details, see todo insert link to data sources overview link advanced features slicing and limiting context arrays apply limit and offset to show only a subset of a large context array { "type" "context", "contextkey" "topauthors", "contextpath" "article authors", "limit" 3 } storing only a specific property use contextproperty to extract a single field from each item — useful for building id lists { "type" "context", "contextkey" "authorids", "contextpath" "article authors", "contextproperty" "id" } $context authorids will be an array of id strings rather than full author objects for more details on value interpolation, see todo insert link to value interpolation link testing notes / edge cases contextpath must point to an array if the resolved value is not an array (e g , a string or object), the data source returns an empty list verify the context structure at runtime using the developer tools path resolution timing the context path is resolved when the data source initializes if the parent context hasn't loaded yet (async), the list will be empty ensure the parent data is loaded before the child list renders — use conditions or loading states to guard against this no caching overhead since no api call is made, maxcacheage and preventssrcache have no effect the data is as fresh as whatever loaded it into context nested path notation both dot notation ( article images ) and bracket notation ( article\['images'] ) are supported in contextpath related topics todo insert link to data sources overview linktodo insert link to custom data source linktodo insert link to value interpolation link