This guide walks you through setting up your own GitHub Streak Card on Cloudflare Workers.
Before you begin, make sure you have:
git clone https://github.com/YOUR-USERNAME/codekunoichi-streak-card.git
cd codekunoichi-streak-card
Replace YOUR-USERNAME with your GitHub username.
Your worker needs a GitHub token to fetch your contribution data.
GitHub Streak Card Worker (or any name you prefer)Select Permissions
You only need ONE permission:
read:user - Read all user profile dataDo NOT select any other permissions. This token only needs to read public contribution data.
ghp_ or github_pat_)Your token will look like:
ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
or
github_pat_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Keep this token secure! You’ll use it in Step 7.
You’ll need this to deploy from your local machine.
Wrangler Deploy (or any name)ypBpd594...You’ll use this token when you first run Wrangler commands. We’ll do this in the deployment guide.
Navigate to your project directory and install npm packages:
npm install
This installs:
wrangler - Cloudflare Workers CLI tooltypescript - TypeScript compiler@cloudflare/workers-types - Type definitions for WorkersCloudflare KV (Key-Value) storage is used to cache your streak SVG for reliability.
npx wrangler login
This will open a browser window to authenticate. Click Allow.
npx wrangler kv:namespace create "STREAK_KV"
You’ll see output like:
🌀 Creating namespace with title "codekunoichi-streak-card-STREAK_KV"
✨ Success!
Add the following to your configuration file in your kv_namespaces array:
{ binding = "STREAK_KV", id = "abc123xyz456..." }
The ID will be something like: 710955b2d5a0416ca03aa0761b403c4b
Save this ID - you’ll use it in the next step.
Now you’ll configure the project with your settings.
wrangler.tomlOpen wrangler.toml in your code editor.
Change the worker name to something unique:
name = "your-username-streak-card" # Change this
main = "src/index.ts"
compatibility_date = "2024-12-19"
Example: name = "johndoe-streak-card"
Replace the id with your namespace ID from Step 5:
[[kv_namespaces]]
binding = "STREAK_KV"
id = "YOUR_KV_NAMESPACE_ID_HERE" # Replace this!
preview_id = "YOUR_KV_NAMESPACE_ID_HERE" # Replace this too!
Example:
[[kv_namespaces]]
binding = "STREAK_KV"
id = "710955b2d5a0416ca03aa0761b403c4b"
preview_id = "710955b2d5a0416ca03aa0761b403c4b"
Change the username to your GitHub username:
[vars]
GITHUB_USERNAME = "your-github-username" # Change this!
Example:
[vars]
GITHUB_USERNAME = "johndoe"
wrangler.tomlname = "johndoe-streak-card"
main = "src/index.ts"
compatibility_date = "2024-12-19"
# KV namespace binding
[[kv_namespaces]]
binding = "STREAK_KV"
id = "710955b2d5a0416ca03aa0761b403c4b"
preview_id = "710955b2d5a0416ca03aa0761b403c4b"
# Environment variables
[vars]
GITHUB_USERNAME = "johndoe"
Save the file.
Your GitHub token should never be committed to Git. Instead, we store it as a Cloudflare secret.
npx wrangler secret put GITHUB_TOKEN
When prompted, paste your GitHub Personal Access Token (from Step 2) and press Enter.
You’ll see:
🌀 Creating the secret for the Worker "your-streak-card"
✨ Success! Uploaded secret GITHUB_TOKEN
GITHUB_TOKENBefore proceeding to deployment, verify:
read:user permissionnpm installwrangler.toml with:
id and preview_id)GITHUB_TOKEN secret via Wrangler CLIIf you want to test locally, create a .dev.vars file for local secrets:
# Create .dev.vars file (NOT committed to Git)
cat > .dev.vars << 'EOF'
# Local development environment variables
GITHUB_TOKEN=your_github_token_here
EOF
Replace your_github_token_here with your actual token.
IMPORTANT: .dev.vars is in .gitignore and should never be committed!
Configuration complete! Now head to the Deployment Guide to:
npm run devMake sure Node.js is installed:
node --version
npm --version
If not installed, download from https://nodejs.org/
Run:
npx wrangler login
Make sure you:
npx wrangler kv:namespace create "STREAK_KV"wrangler.toml in both id and preview_id fieldsMake sure your token has the read:user permission. You can check and regenerate at https://github.com/settings/tokens
| ← Back to Index | Next: Deployment Guide → |