About this project
Real-time Visitor Counter in Turbo Monorepo is an open-source project that demonstrates live visitor tracking using WebSockets. The application counts unique visitors per URL "room" and aggregates totals across all active rooms.
Architecture: The project follows a Turborepo monorepo layout. The frontend lives in client/ as a Vue 3 + Vite application. The backend resides in server/ as a Cloudflare Worker backed by Durable Objects for persistent, real-time state. Communication between layers happens through WebSockets.
Features:
- Per-room visitor counting based on the current browser URL
- Global visitor count across all simultaneously active rooms
- Dynamic environment switching: development uses ws://localhost:8787, production uses wss:// configured URLs
- Hot-reload dev server via turbo dev
Tech stack:
- Frontend: Vue 3, Vite
- Backend: Cloudflare Workers, Cloudflare Durable Objects
- Monorepo orchestration: Turborepo
- Package manager: pnpm
Prerequisites:
- Node.js and pnpm
- A Cloudflare account with Workers enabled
- wrangler CLI installed globally
- Turborepo installed globally
Installation and setup:
1. Clone the repository and run pnpm install from the root.
2. Install turbo and wrangler globally via pnpm.
3. Authenticate wrangler with wrangler login.
4. Configure wrangler.toml in both client/ and server/ directories.
5. Run turbo dev to start both the dev server and local worker.
6. Visit http://localhost:5175 in multiple tabs or devices to observe real-time updates.
Deployment is handled through turbo deploy from the relevant apps/worker directory.
Demo: https://wsdemo.cvyl.me
Repository: cvyl/cloudflare-websocket-livecount
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.