Skip to content
p32929Public

About

Self-hostable CDN for GitHub files and Gists — paste a repo URL, get a usable script/style/fetch URL

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

GitHub CDN

Paste a GitHub file or Gist URL, get a CDN URL you can drop straight into a <script>, <link> or fetch(). Self-hostable Next.js app — a jsDelivr-style alternative you run yourself.

Live: https://ghcdn.vercel.app

Screenshots

Image

Features

  • Serve GitHub repository files directly via CDN URL
  • Serve Gist content directly via CDN URL
  • Memory-efficient caching for faster delivery
  • Purge cached content when needed
  • Modern, responsive UI with excellent user experience

URL Format

GitHub Repository Files

https://github.com/{username}/{repo}/{branch}/{path}

Example:

https://github.com/p32929/p32929.github.io/blob/react/README.md

Gist Files

https://gist.github.com/{username}/{gistId}

Example:

https://gist.github.com/p32929/7a2375cf2eb3d2986a741d7dc293a4c8

When to Use GitHub CDN

Here are 5 practical examples of when GitHub CDN is useful:

  1. Serving JavaScript Libraries in Web Pages

    <script src="https://your-cdn-domain.com/github/username/repo/branch/path/to/script.js"></script>
  2. Loading CSS Stylesheets

    <link rel="stylesheet" href="https://your-cdn-domain.com/github/username/repo/branch/path/to/styles.css">
  3. Embedding Code Snippets from Gists

    <script src="https://your-cdn-domain.com/gist/username/gistId"></script>
  4. Fetching JSON Configuration Files

    fetch('https://your-cdn-domain.com/github/username/repo/branch/path/to/config.json')
      .then(response => response.json())
      .then(data => console.log(data));
  5. Serving Text Content and Documentation

    <iframe src="https://your-cdn-domain.com/github/username/repo/branch/path/to/documentation.md" 
      width="100%" height="500px"></iframe>

Limitations

GitHub CDN has some limitations you should be aware of:

  1. Binary Files: Not optimized for serving large binary files or applications.

  2. Image Files: While technically possible, the CDN is not optimized for image delivery. Consider using dedicated image hosting services for better performance.

  3. Rate Limiting: Subject to GitHub API rate limits if you don't provide a GitHub token.

  4. Private Repositories: Does not support private repositories unless you provide authentication.

  5. Frequent Updates: If your content changes frequently, you may need to manually purge the cache.

Getting Started

Prerequisites

  • Node.js 18.x or later
  • npm or yarn

Installation

  1. Clone the repository
git clone https://github.com/p32929/ghcdn.git
cd ghcdn
  1. Install dependencies:
npm install
# or
yarn
  1. Start the development server:
npm run dev
# or
yarn dev
  1. Open http://localhost:3000 in your browser

Environment Variables

Create a .env file with the following variables:

GITHUB_TOKEN=your_github_token  # Optional, but recommended for higher rate limits

Deployment

Deploy GitHub CDN with one click to your preferred platform:

Quick Deploy Options

Deploy with Vercel Deploy to Netlify Deploy on Railway

Deploy to Render Deploy to DigitalOcean Deploy to Heroku

Deploy to Amplify Deploy to Koyeb

Additional Platforms

  • Cloudflare Pages: Fork the repo and import it in Cloudflare Pages
  • Fly.io: Run fly launch in the cloned repository
  • Cyclic: Import from Cyclic Dashboard
  • Northflank: Create project from Northflank
  • Deta Space: Use space push after installing Space CLI
  • Replit: Import directly from Replit
  • Glitch: Remix on Glitch
  • Surge.sh: Deploy with surge after building locally
  • GitHub Pages: Use GitHub Actions for deployment (static export required)
  • Azure Static Web Apps: Deploy via Azure Portal

All platforms will auto-detect Next.js and apply appropriate build settings. No additional configuration files needed!

Docker

Run with Docker:

docker build -t ghcdn .
docker run -p 3000:3000 -e GITHUB_TOKEN=your_token ghcdn

Environment Variables

Variable Required Description
GITHUB_TOKEN No GitHub personal access token for higher API rate limits (Create token)

Most platforms will prompt you to add environment variables during deployment.

License

MIT License — Copyright (c) 2025 Fayaz Bin Salam. See LICENSE for the full text.

Contributing

Contributions are warmly welcomed and greatly appreciated! Whether it's a bug fix, new feature, or improvement, your input helps make this project better for everyone.

Before submitting a pull request, please:

  1. Create an issue describing the feature or bug fix you'd like to work on
  2. Wait for discussion and approval to ensure alignment with project goals
  3. Fork the repository and create your feature branch
  4. Submit your pull request with a clear description of changes

This approach helps avoid duplicate efforts and ensures smooth collaboration. Thank you for considering contributing!

Share

Sharing this repository with your friends is just one click away from here

facebook twitter tumblr pocket pinterest reddit linkedin whatsapp


💼 Using this at a company?

I do fixed-price delivery work on my own projects. One invoice, one date, no hourly billing:

White-label build — this project rebranded, extended and deployed as yours $6,500 · 3 weeks
Custom app from scratch on my own stack, signed and auto-updating $12,500 · 6 weeks
Production-hardening sprint — 72 hours on this project, for your load and your security review $999
Ongoing capacity — one project-week of my time reserved every month $9,000 / month

Full details → p32929.github.io/hire · Email fayazdevinbox@uberip.com — scoping and quotes are free and I answer within one business day.

About

Self-hostable CDN for GitHub files and Gists — paste a repo URL, get a usable script/style/fetch URL

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages