A privacy-friendly counter for page views

@yeger/page-views

Documentation

A privacy-friendly counter for page views.

Features

  • ??‍♂️ Privacy-friendly: No user-tracking. Clients decide when to submit a page view.
  • ? Lightweight & Simple: Less than a kilobyte gzipped. Can be configured to automatically submit views, even after client-side navigation.
  • ? Self-hostable: By default, a public instance of the backend is used. Alternatively, a self-hosted instance or a custom backend adhering to the scheme can be used.

Installation

# yarn
$ yarn add @yeger/page-views

# npm
$ npm install @yeger/page-views

Usage

import PageViews from '@yeger/page-views'

// Manually submit a view of the current page
await PageViews.submitView()

// Automatically submit views
PageViews.autoSubmitViews()

// Get views of current page
await PageViews.getViews()

Examples

React and Vue examples can be found here.

Development

# install dependencies
$ yarn install

# build for production
$ yarn build

# build in watch mode
$ yarn dev

# lint project files
$ yarn lint

# serve docs
$ yarn docs:dev

License

MIT – Copyright © Jan Müller

GitHub

View Github