Custom Data Source
8 min
overview the custom data source lets you define a static list of items directly inside views json no api call is made — the items are embedded in the configuration and available immediately it is useful for fixed navigation links, static option lists, hard coded tabs, or any list whose content never changes at runtime when to use this use custom for lists that are fully controlled by the developer and do not require fetching from any external source if the items need to come from an api or change based on user state, use a different data source type basic example { "type" "custom", "contextkey" "navlinks", "items" \[ { "label" "home", "url" "/home" }, { "label" "archive", "url" "/archive" }, { "label" "about", "url" "/about" } ] } this makes the three items available as $context navlinks immediately, with no api request child components can iterate over the list and render each item using its label and url properties configuration type specific properties property type default description items array — required the static list of items each element can be any json object common configuration (inherited) all common data source properties apply — contextkey , limit , offset , randomize , etc batchsize , maxcacheage , and preventssrcache have no effect since there is no api call for more details, see todo insert link to data sources overview link advanced features using conditional values in items individual item properties can use $context values for dynamic labels or urls, even though the list itself is static { "type" "custom", "contextkey" "tabs", "items" \[ { "label" "latest", "filter" "latest" }, { "label" "popular", "filter" "popular" } ] } combining with randomize the randomize property works with custom items — useful for rotating static promotional banners { "type" "custom", "contextkey" "promos", "randomize" true, "limit" 1, "items" \[ { "image" "promo a jpg", "url" "/offer a" }, { "image" "promo b jpg", "url" "/offer b" } ] } testing notes / edge cases limit and offset work normally even though items are static, limit and offset apply as expected a limit 1 with randomize true picks one random item empty items array an empty array \[] is valid and produces an empty list the component renders its empty state large static lists for lists with many items, consider whether a json data source with a local resource file is more maintainable — it keeps items out of views json related topics todo insert link to data sources overview linktodo insert link to json data source linktodo insert link to context data source link