counters.get(name, [counterFile]) Last updated: 30. May 2026

API only function

Retrieves the current numerical value of a named counter, allowing you to monitor and track the state of various counters in your application.

Parameters

Name Type Description
name string

The name of the counter to retrieve.

counterFile (optional) string

Absolute file path to counter file.
Default is "#/counters.json" if not specified.

Returns

The current counter value as a number.

Example

Data

Returns the current value of the specified counter as a number.

Code example (JS)

JS is normal JavaScript either 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);