Convert Figma logo to code with AI

unpkg logounpkg

The CDN for everything on npm

3,284
318
3,284
38

Top Related Projects

A free, fast, and reliable Open Source CDN for npm, GitHub, Javascript, and ESM

10,581

🤖 CDN assets - The #1 free and open source CDN built to make life easier for developers.

3,680

A nobuild content delivery network(CDN) for modern web development.

Quick Overview

unpkg is a fast, global content delivery network (CDN) for everything on npm. It allows you to quickly and easily load any file from any package using a URL like unpkg.com/:package@:version/:file. This service is particularly useful for developers who want to use npm packages directly in the browser without setting up a build process.

Pros

  • Fast and reliable global CDN for npm packages
  • Easy to use with a simple URL structure
  • Supports versioning, allowing access to specific package versions
  • Provides a browsable interface for exploring package contents

Cons

  • Dependency on external service for production applications
  • Limited control over caching and updates
  • Potential security risks if not used carefully with trusted packages
  • May not be suitable for large-scale applications with high traffic

Getting Started

To use unpkg in your project, simply include the desired package in your HTML file using a script tag:

<script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>

You can also use unpkg to load specific files from a package:

<script src="https://unpkg.com/lodash@4.17.21/lodash.min.js"></script>

For CSS files, use a link tag:

<link rel="stylesheet" href="https://unpkg.com/bootstrap@5.3.0/dist/css/bootstrap.min.css">

Remember to specify the desired version to ensure consistency and avoid unexpected changes in your application.

Competitor Comparisons

A free, fast, and reliable Open Source CDN for npm, GitHub, Javascript, and ESM

Pros of jsDelivr

  • Supports multiple CDN providers, offering better global coverage and redundancy
  • Allows serving specific file versions and auto-minification
  • Provides additional features like combining multiple files and setting custom headers

Cons of jsDelivr

  • More complex configuration options may be overwhelming for simple use cases
  • Slightly longer URLs for basic file serving compared to unpkg

Code Comparison

unpkg:

https://unpkg.com/react@17.0.2/umd/react.production.min.js

jsDelivr:

https://cdn.jsdelivr.net/npm/react@17.0.2/umd/react.production.min.js

Both CDNs offer similar URL structures for serving npm packages. The main difference is in the base URL, with jsDelivr using cdn.jsdelivr.net/npm/ and unpkg using unpkg.com/.

jsDelivr provides additional URL parameters for advanced usage:

https://cdn.jsdelivr.net/combine/npm/react@17.0.2,npm/react-dom@17.0.2

This feature allows combining multiple files in a single request, which is not available in unpkg.

Both repositories aim to provide fast and reliable CDN services for npm packages, with jsDelivr offering more advanced features and global coverage, while unpkg focuses on simplicity and ease of use.

10,581

🤖 CDN assets - The #1 free and open source CDN built to make life easier for developers.

Pros of cdnjs

  • Extensive library of pre-hosted files for popular frameworks and libraries
  • Versioning support for multiple releases of each library
  • Community-driven project with a large contributor base

Cons of cdnjs

  • Limited to pre-approved libraries, not all packages available
  • Slower update cycle for new versions compared to real-time npm registry
  • Requires manual submission and review process for new libraries

Code comparison

cdnjs usage:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

unpkg usage:

<script src="https://unpkg.com/jquery@3.6.0/dist/jquery.min.js"></script>

Key differences

  • cdnjs hosts a curated selection of popular libraries, while unpkg serves any package from the npm registry
  • unpkg generates URLs dynamically based on npm package versions, cdnjs uses a static file structure
  • cdnjs requires manual updates and approvals, unpkg reflects npm registry changes in real-time
  • unpkg offers more flexibility for accessing specific files within packages
  • cdnjs may have better performance due to its dedicated infrastructure and limited scope

Both services provide valuable CDN options for developers, with cdnjs offering a more curated experience and unpkg providing broader access to the npm ecosystem.

3,680

A nobuild content delivery network(CDN) for modern web development.

Pros of esm.sh

  • Specializes in serving ES modules, optimized for modern JavaScript development
  • Offers TypeScript support and automatic type definitions
  • Provides a CDN-like experience specifically tailored for ES modules

Cons of esm.sh

  • More limited package selection compared to unpkg's vast npm ecosystem
  • Less established and potentially less stable than the more mature unpkg

Code Comparison

esm.sh:

import React from 'https://esm.sh/react'
import { useState } from 'https://esm.sh/react'

unpkg:

import React from 'https://unpkg.com/react?module'
import { useState } from 'https://unpkg.com/react?module'

Key Differences

  • esm.sh focuses on ES modules, while unpkg serves all npm packages
  • esm.sh provides TypeScript support out of the box
  • unpkg has a larger package selection due to its direct connection to npm
  • esm.sh offers a more streamlined experience for modern JavaScript development
  • unpkg is more versatile, serving both modules and traditional scripts

Both services aim to simplify package usage in browser environments, but esm.sh caters specifically to ES module needs, while unpkg provides broader access to the npm ecosystem. The choice between them depends on specific project requirements and preferences for module handling.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

UNPKG

Welcome to UNPKG!

UNPKG is a fast, global content delivery network for everything on npm. Use it to quickly and easily load any file from npm using a URL like:

https://unpkg.com/:package@:version/:file

Where :package is the package name, :version is the version range, and :file is the path to the file in the package.

You can learn more about UNPKG on the website.

Development

This repository contains the production source for UNPKG. There are 4 packages:

  • unpkg-app is the UNPKG web app (file browser)
  • unpkg-files is the file server backend that fetches tarballs from npm and extracts their contents
  • unpkg-worker is a shared set of utilites between the web apps (Cloudflare workers)
  • unpkg-www is the main UNPKG app

We use Bun in development, as well as pnpm. Install these first.

Next, install all dependencies and run the tests:

pnpm install
pnpm test

Then start the file server and each worker along with its assets server (you'll need 5 terminal tabs):

cd packages/unpkg-files && pnpm dev
cd packages/unpkg-www && pnpm dev
cd packages/unpkg-www && pnpm dev:assets
cd packages/unpkg-app && pnpm dev
cd packages/unpkg-app && pnpm dev:assets

The dev server will be listening on http://localhost:3000.

Deploying

The unpkg-files backend is deployed on Fly.io. You'll need an account.

Next, adjust the Fly config in packages/unpkg-files/fly.json (you'll need your own app name) and deploy:

cd packages/unpkg-files && pnpm run deploy

To deploy the workers, you'll need a Cloudflare account. You will also need to (1) edit the wrangler.json file in each worker and update its routes to your own domain(s) and (2) adjust each worker's environment vars (in wrangler.json) so they can find one another in production.

Once you've done that, you can deploy each worker with:

cd packages/unpkg-www && pnpm run deploy
cd packages/unpkg-app && pnpm run deploy

License

Please see LICENSE for more information.

NPM DownloadsLast 30 Days