Function API only Updated 17 Oct 2026
counters.get(name, [counterFile])
Retrieves the current numerical value of a named counter, allowing you to monitor and track the state of various counters in your application.
Parameters
namestringrequiredThe name of the counter to retrieve.
counterFilestringoptionalAbsolute file path to counter file.
Default is "#/counters.json" if not specified.
Returns
The current counter value as a number. null when the counter file or the named counter does not exist.
Example
Normal JavaScript, running in the browser or on the Docly™ server.
// Get the current value of the 'pageViews' counter
let currentPageViews = counters.get('pageViews');
console.log('Current page views:', currentPageViews);The data the example runs with:
Returns the current value of the specified counter as a number.