unpkg is a fast, global content delivery network for everything onnpm.Use it to quickly and easily load any file from any package using a URL like:
Using a fixed version:
You may also use asemver rangeor ataginstead of a fixed version number, or omit the version/tag entirely to use thelatest
tag.
If you omit the file path (i.e. use a “bare” URL), unpkg will serve the file specified by theunpkg
field inpackage.json
,or fall back tomain
.
Append a/
at the end of a URL to view a listing of all the files in a package.
?meta
/any/file?meta
)?module
import
specifiersin JavaScript modules to unpkg URLs. This feature isvery experimentalThe CDN caches files based on their permanent URL, which includes the npm package version. This works because npm does not allow package authors to overwrite a package that has already been published with a different one at the same version number.
Browsers are instructed (via theCache-Control
header) to cache assets indefinitely (1 year).
URLs that do not specify a package version number redirect to one that does. This is thelatest
version when no version is specified, or themaxSatisfying
version when asemver versionis given. Redirects are cached for 10 minutes at the CDN, 1 minute in browsers.
If you want users to be able to use the latest version when you cut a new release, the best policy is to put the version number in the URL directly in your installation instructions. This will also load more quickly because we won't have to resolve the latest version and redirect them.
For npm package authors, unpkg relieves the burden of publishing your code to a CDN in addition to the npm registry. All you need to do is include yourUMDbuild in your npm package (not your repo, that's different!).
You can do this easily using the following setup:
umd
(ordist
) directory to your.gitignore
fileumd
directory to yourfiles arrayinpackage.json
umd
directory when you publishThat's it! Now when younpm publish
you'll have a version available on unpkg as well.
unpkg is anopen sourceproject built and maintained byMichael Jackson.unpkg is not affiliated with or supported by npm, Inc. in any way. Please do not contact npm for help with unpkg. Instead, please reach out to@unpkgwith any questions or concerns.
The unpkg CDN is powered byCloudflare,one of the world's largest and fastest cloud network platforms.
The origin server runs on auto-scaling infrastructure provided byFly.io.The app servers run in 17 cities around the world, and come and go based on active requests.