Package Exports
- countty
- countty/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (countty) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Countty ✚
Easily persist your own Page View Counter for free.
- Based on Durable Objects and ready for use via Cloudflare Workers ⛅️
- No VPS or Database plans required 💳
- No server or database configuration/setup required ✨
- Experimental: under development 🚧
🧪 Quick Test Locally
You can test it locally, even if you don't have a Cloudflare account.
📦 Install
npm i countty⛅️ Worker
Create the files:
index.js
import { createCountty } from 'countty';
const { worker, Countty } = createCountty();
export default worker;
export { Countty };wrangler.json
{
"main": "index.js",
"compatibility_date": "2025-09-24",
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [
{
"name": "countty",
"class_name": "Countty"
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["Countty"]
}
]
}🏁 Run
npx -y wrangler devYou can also install wrangler as a development dependency:
npm i -D wrangler🔗 API Routes
/create: private
fetch('http://localhost:8787/create?slug=test', {
headers: {
Authorization: 'Bearer 123456',
},
})
.then((res) => res.json())
.then(console.log);/views: public
fetch('http://localhost:8787/views?slug=test')
.then((res) => res.json())
.then(console.log);localhost:8787/backup: private
fetch('/backup', {
headers: {
Authorization: 'Bearer 123456',
},
})
.then((res) => res.text())
.then(console.log);[!IMPORTANT]
By default, the token for private routes is
"123456". To change it, follow the steps below.
🔐 Production Usage
For production use, you will need a Cloudflare account to proceed.
⛅️ Create your worker
npx wrangler deploy🔑 Personalize your Token
To use in production, please create your personal token:
npx wrangler secret put TOKEN # Then press `Enter` to insert your token[!TIP]
Create an
.envfile with theTOKENvariable to use the same token locally.
🐬 SQL Options
You can change the table name by specifying the name when creating Countty:
import { createCountty } from 'countty';
const { worker, Countty } = createCountty('my-table');
export default worker;
export { Countty };⚖️ Restrictions on the free plan:
- Workers: https://developers.cloudflare.com/workers/platform/pricing/
- Durable Objects (SQLite): https://developers.cloudflare.com/durable-objects/platform/pricing/