{"id":51325208,"url":"https://github.com/dipcb05/githubvisitcounter","last_synced_at":"2026-07-01T17:32:59.301Z","repository":{"id":365821710,"uuid":"1273912608","full_name":"dipcb05/githubvisitcounter","owner":"dipcb05","description":"Self-hosted GitHub profile view counter and customizable README badge generator.","archived":false,"fork":false,"pushed_at":"2026-06-19T02:52:04.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-19T04:22:16.377Z","etag":null,"topics":["github","github-counter"],"latest_commit_sha":null,"homepage":"https://githubvisitcounter.dipchakraborty.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dipcb05.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-19T02:09:16.000Z","updated_at":"2026-06-19T02:49:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dipcb05/githubvisitcounter","commit_stats":null,"previous_names":["dipcb05/githubvisitcounter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dipcb05/githubvisitcounter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipcb05%2Fgithubvisitcounter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipcb05%2Fgithubvisitcounter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipcb05%2Fgithubvisitcounter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipcb05%2Fgithubvisitcounter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dipcb05","download_url":"https://codeload.github.com/dipcb05/githubvisitcounter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipcb05%2Fgithubvisitcounter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35017089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-counter"],"created_at":"2026-07-01T17:32:59.140Z","updated_at":"2026-07-01T17:32:59.288Z","avatar_url":"https://github.com/dipcb05.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# githubvisitcounter\n\nA self-hosted GitHub profile view counter and customizable README badge generator built with Next.js, Upstash Redis, and TypeScript.\n\ngithubvisitcounter lets you run your own profile view badge service instead of depending on a third-party counter. It exposes a lightweight SVG badge endpoint, stores counts in Redis, and includes a polished web UI for generating badge URLs and copy-ready HTML.\n\n## Features\n\n- Generate GitHub-compatible SVG profile view badges\n- Increment and store profile views with Upstash Redis\n- Customize badge label, color, username, and style\n- Preview badges in the browser before copying them\n- Copy ready-to-use HTML for a GitHub profile README\n- Optional GitHub profile stats for followers, following, public repos, and total stars\n- Lightweight API endpoint designed for README image embeds\n- Works with any deployment platform that supports Next.js and environment variables\n\n## How It Works\n\nThe app has two main parts:\n\n1. A web interface where you enter a GitHub username and customize the badge.\n2. An API route at `/api/profile-views` that increments a Redis counter and returns an SVG badge.\n\nWhen a badge is loaded in a README, GitHub requests the SVG image URL. That request hits the API, increments the stored count for the selected username, and returns the latest count as a badge image.\n\n## Tech Stack\n\n- Next.js\n- Upstash Redis\n- GitHub REST API\n\n## Requirements\n\n- Node.js compatible with Next.js 16\n- pnpm\n- Upstash Redis database\n- Optional GitHub personal access token for GitHub stats\n\n## Getting Started\n\nInstall dependencies:\n\n```bash\npnpm install\n```\n\nCreate a local environment file:\n\n```bash\ncp .env.example .env.local\n```\n\nAdd your Upstash Redis credentials:\n\n```env\nKV_REST_API_URL=https://your-project.upstash.io\nKV_REST_API_TOKEN=your_upstash_token_here\n```\n\nOptionally add a GitHub token if you want the UI to show GitHub profile stats:\n\n```env\nGITHUB_API_TOKEN=ghp_your_github_personal_access_token_here\n```\n\nStart the development server:\n\n```bash\npnpm dev\n```\n\nOpen:\n\n```text\nhttp://localhost:3000\n```\n\n## Environment Variables\n\n| Variable | Required | Description |\n| --- | --- | --- |\n| `KV_REST_API_URL` | Yes | Upstash Redis REST API URL |\n| `KV_REST_API_TOKEN` | Yes | Upstash Redis REST API token |\n| `GITHUB_API_TOKEN` | No | GitHub token used for optional profile stats |\n| `NEXT_PUBLIC_APP_URL` | No | Public app URL used by the badge generator UI |\n\n## Badge Usage\n\nUse the app UI to generate a badge, or build the URL manually:\n\n```text\nhttps://yourdomain.com/api/profile-views?username=yourname\u0026label=Profile%20views\u0026color=0e75b6\u0026style=flat\n```\n\nAdd it to a GitHub README:\n\n```html\n\u003cimg src=\"https://yourdomain.com/api/profile-views?username=yourname\u0026label=Profile%20views\u0026color=0e75b6\u0026style=flat\" alt=\"profile views\" /\u003e\n```\n\nMarkdown also works:\n\n```md\n![Profile views](https://yourdomain.com/api/profile-views?username=yourname\u0026label=Profile%20views\u0026color=0e75b6\u0026style=flat)\n```\n\nReplace `yourdomain.com` with the domain where you deploy the app, and replace `yourname` with the GitHub username or counter key you want to track.\n\n## API Reference\n\n### `GET /api/profile-views`\n\nReturns an SVG badge and increments the counter for the provided `username`.\n\n| Parameter | Type | Default | Description |\n| --- | --- | --- | --- |\n| `username` | string | `guest` | GitHub username or custom counter key |\n| `label` | string | `Profile views` | Text shown on the left side of the badge |\n| `color` | string | `0e75b6` | Hex color for the right side of the badge |\n| `style` | string | `flat` | Badge style: `flat`, `flat-square`, or `plastic` |\n\nExample:\n\n```text\n/api/profile-views?username=dipcb05\u0026label=Profile%20views\u0026color=0e75b6\u0026style=flat\n```\n\nThe API response uses:\n\n- `Content-Type: image/svg+xml`\n- `Cache-Control: no-cache, no-store, must-revalidate`\n\nThe no-cache headers help keep the displayed counter fresh when the badge is requested.\n\n## GitHub Stats\n\nThe badge counter itself only needs Upstash Redis. GitHub stats are optional and are used by the web UI to show extra profile information.\n\nWith `GITHUB_API_TOKEN` configured, the app can fetch:\n\n- Followers\n- Following\n- Public repositories\n- Total stars across public repositories\n\nIf the token is missing or the GitHub API request fails, the badge generator still works.\n\n## Scripts\n\n```bash\npnpm dev\n```\n\nStart the local development server.\n\n```bash\npnpm build\n```\n\nCreate a production build.\n\n```bash\npnpm start\n```\n\nRun the production build.\n\n```bash\npnpm lint\n```\n\nRun linting.\n\n## Deployment\n\nDeploy githubvisitcounter anywhere that can run a Next.js app and provide environment variables. The only required backing service is Upstash Redis.\n\nFor production, make sure these values are configured in your hosting provider:\n\n```env\nKV_REST_API_URL=...\nKV_REST_API_TOKEN=...\nNEXT_PUBLIC_APP_URL=https://yourdomain.com\n```\n\nAdd `GITHUB_API_TOKEN` only if you want profile stats in the generator UI.\n\nAfter deployment, use your production domain in the badge URL:\n\n```text\nhttps://yourdomain.com/api/profile-views?username=yourname\n```\n\n## Project Structure\n\n```text\napp/\n  api/profile-views/route.ts  SVG badge API route\n  layout.tsx                  Root metadata and layout\n  page.tsx                    Home page\ncomponents/\n  badge-generator.tsx         Main badge generator UI\ncomponents/ui/\n  button.tsx                  Shared button component\nlib/\n  badge-utils.ts              Badge URL and embed helpers\n  github-stats.ts             Optional GitHub API helpers\npublic/\n  icons and public assets\n```\n\n## Troubleshooting\n\nIf the badge returns an error, check that `KV_REST_API_URL` and `KV_REST_API_TOKEN` are set correctly.\n\nIf the badge works locally but not in a GitHub README, make sure the deployed URL is public and returns an SVG when opened directly in the browser.\n\nIf GitHub stats do not show in the UI, confirm that `GITHUB_API_TOKEN` is configured and has access to public user and repository data.\n\nIf the counter appears stale on GitHub, wait a few minutes. GitHub may cache external images even when the API response asks clients not to cache them.\n\n## License\n\nMIT. See [LICENSE](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipcb05%2Fgithubvisitcounter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdipcb05%2Fgithubvisitcounter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipcb05%2Fgithubvisitcounter/lists"}