A modern, minimal website that compares the market capitalization of Bitcoin and Gold with daily updated data and visual charts.
Check out the live demo: https://btc-vs-gold.vercel.app
- Real-time market cap comparison between Bitcoin and Gold
- Manual refresh button - click the π icon to fetch fresh data instantly
- Interactive visual charts with custom icons
- Modern dark theme with colorful gradient backgrounds
- Fully responsive (mobile, tablet, desktop)
- No API keys required - works out of the box!
- Zero hosting cost on Vercel free tier
- TypeScript for type safety
- Tailwind CSS for styling
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Charts: Recharts
- APIs (all free, no authentication required):
- CoinGecko API (Bitcoin data)
- GoldAPI.io demo token (Gold price)
- GoldPrice.org (Gold price fallback)
- Node.js 18+ installed
- npm or yarn package manager
- That's it! No API keys needed!
- Clone the repository:
git clone <your-repo-url>
cd btc-vs-gold- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
That's it! The app works out of the box with no configuration needed.
If you want to customize the site URL (mainly for production):
cp .env.example .env.localThen edit .env.local if needed. But this is optional for local development.
This project uses completely free, public APIs that don't require any authentication or signup:
- Bitcoin data: CoinGecko API (free tier, no key needed)
- Gold price: GoldAPI.io demo token + GoldPrice.org fallback (no signup needed)
All APIs used are free and public, so you can start using the app immediately without any setup!
The app uses client-side data fetching with a manual refresh button:
- On page load, the app fetches initial data from the
/api/refreshendpoint - Data is displayed with Bitcoin and Gold market information
- Click the π button to fetch fresh data on-demand
- The button changes to β³ while loading
- All data updates instantly when the request completes
This approach:
- Gives you control over when to fetch fresh data
- Provides instant updates when you need them
- Stays within free tier limits (no automatic polling)
- Shows real-time data whenever you refresh
Bitcoin: Market cap is provided directly by CoinGecko API
Gold: Market cap is calculated using:
Gold Market Cap = Current Gold Price Γ Total Above-Ground Supply
= Price per Troy Ounce Γ 6.95 Billion Troy Ounces
β $2,650 Γ 6,950,000,000
β $18.4 Trillion
btc-vs-gold/
βββ app/
β βββ api/
β β βββ refresh/
β β βββ route.ts # Manual refresh API endpoint
β βββ layout.tsx # Root layout
β βββ page.tsx # Main page (client component)
β βββ globals.css # Global styles
βββ components/
β βββ Header.tsx # Page header with refresh button
β βββ MarketCapCard.tsx # Market cap display card
β βββ ComparisonChart.tsx # Horizontal bar chart
βββ lib/
β βββ api.ts # API fetching functions
β βββ constants.ts # Constants (gold supply, colors)
β βββ utils.ts # Utility functions
βββ types/
β βββ index.ts # TypeScript type definitions
βββ public/
β βββ bitcoin.png # Bitcoin icon
β βββ gold-bars.png # Gold icon
β βββ webpage.png # Screenshot
βββ .env.example # Environment variables template
-
Push your code to GitHub
-
Go to vercel.com and sign up/login
-
Click "New Project" and import your GitHub repository
-
Click "Deploy"
That's it! No environment variables or configuration needed.
Your site will be live in seconds with:
- Automatic HTTPS
- Global CDN
- Automatic redeployment on git push
- Manual refresh button - click π to get fresh data anytime
The project features a manual refresh button for on-demand data updates:
- Refresh button: Click the π icon in the header
- What it does: Fetches fresh Bitcoin and Gold data from the APIs
- Visual feedback: Shows β³ while loading, then returns to π
- Instant updates: All market data refreshes immediately
- Cost: Free on Vercel - no limits on refresh requests
While this app is optimized for Vercel, you can also deploy to GitHub Pages:
- Update
next.config.js:
const nextConfig = {
output: 'export',
images: { unoptimized: true },
}- Build and export:
npm run build- Deploy the
out/directory to GitHub Pages
Note: API routes won't work on GitHub Pages. You'll need to use client-side fetching or a different hosting solution.
Edit tailwind.config.ts and lib/constants.ts:
// tailwind.config.ts
colors: {
bitcoin: "#F7931A", // Bitcoin orange
gold: "#FFD700", // Gold yellow
background: "#0A0A0A", // Near black
card: "#1A1A1A", // Dark gray
}Edit components/Header.tsx to change the button appearance:
// Change the emoji when refreshing
{isRefreshing ? "β³" : "π"}
// Or customize the hover effect
className="hover:scale-110 active:scale-95 transition-transform"- Lighthouse Score: 95+ Performance
- First Load: < 2 seconds
- Bundle Size: < 200KB
- API Calls: Based on usage (free tiers are very generous)
Total Cost: $0/month
| Service | Plan | Cost | Usage | Auth Required |
|---|---|---|---|---|
| CoinGecko API | Free | $0 | On-demand (manual refresh) | No |
| GoldAPI.io | Demo | $0 | Unlimited | No (demo token) |
| GoldPrice.org | Free | $0 | On-demand (manual refresh) | No |
| Vercel Hosting | Hobby | $0 | Unlimited | No |
Note: API calls only happen when you click the refresh button, keeping usage minimal and well within free tier limits.
This usually happens during build time when the local server isn't running yet. It's normal and won't affect the deployed site. If you see this in production:
- Check your network connection
- The app will automatically fall back to estimated gold prices if APIs are unavailable
- Wait 24 hours for ISR to revalidate and try fetching fresh data
- Ensure Recharts is installed:
npm install recharts - Check browser console for errors
- Verify data is being fetched correctly in the Network tab
- Make sure Tailwind CSS is configured correctly
- Check that
globals.cssis imported inlayout.tsx - Run
npm run devto rebuild Tailwind classes
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this project for any purpose.
- Bitcoin data provided by CoinGecko
- Gold price data provided by Metals API
- Built with Next.js
- Charts powered by Recharts
