Using a fixed version:
If you omit the file path (i.e. use a “bare” URL), unpkg will serve the file specified by the
unpkg field in
package.json, or fall back to
/ at the end of a URL to view a listing of all the files in a package.
The 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.
URLs that do not specify a package version number redirect to one that does. This is the
latest version when no version is specified, or the
maxSatisfying version when a semver version is given. Redirects are cached for 5 minutes.
Browsers are instructed (via the
Cache-Control header) to cache assets for 1 year.
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 your UMD build in your npm package (not your repo, that's different!).
You can do this easily using the following setup:
dist) directory to your
umddirectory to your files array in
umddirectory when you publish
That's it! Now when you
npm publish you'll have a version available on unpkg as well.
unpkg is an open source project built and maintained by Michael 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 @unpkg with any questions or concerns.
The unpkg CDN is powered by Cloudflare, one of the world's largest and fastest cloud network platforms.
The origin servers for unpkg are powered by Google Cloud and made possible by a generous donation from the Angular web framework, one of the world's most popular libraries for building incredible user experiences on both desktop and mobile.