<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="description" content="The CDN for everything on npm"/><link rel="icon" type="image/jpeg" href="/favicon.jpg"/><link rel="stylesheet" href="https://unpkg.com/_assets/styles-LG6W3OHZ.css"/><link rel="stylesheet" href="https://unpkg.com/_assets/code-light-B2LHUSJR.css"/><script type="importmap">{"imports":{"preact":"https://unpkg.com/preact@10.25.4/dist/preact.module.js","preact/hooks":"https://unpkg.com/preact@10.25.4/hooks/dist/hooks.module.js","preact/jsx-runtime":"https://unpkg.com/preact@10.25.4/jsx-runtime/dist/jsxRuntime.module.js"}}</script><script type="module" src="https://unpkg.com/_assets/scripts-CHMOEL4U.js" defer></script><title>UNPKG</title><script async src="https://www.googletagmanager.com/gtag/js?id=UA-140352188-1"></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-140352188-1');</script></head><body><header class="mx-auto lg:max-w-screen-md"><h1 class="mt-32 text-7xl text-center font-black text-black">UNPKG</h1></header><main class="mx-auto lg:max-w-screen-md text-slate-900 leading-relaxed max-w-full"><div class="relative mt-16 mb-32 px-8 lg:mt-32"><div><section id="overview"><p>UNPKG is a fast, global content delivery network for everything on <a class="text-blue-600 hover:underline" href="https://www.npmjs.com/">npm</a>. Use it to quickly and easily load any file on npm using a URL like:</p><p class="mt-12 p-4 text-center bg-slate-100"><code class="text-sm sm:hidden">unpkg.com/:pkg@:ver/:file</code><code class="text-sm hidden sm:block">https://unpkg.com/:package@:version/:file</code></p><ul class="mt-12 ml-6 list-disc list-outside"><li class="marker:pr-2"><span><code class="text-sm bg-slate-100 sm:hidden">:pkg</code><code class="text-sm bg-slate-100 hidden sm:inline">:package</code></span> is the name of the package on npm</li><li class="marker:pr-2"><span><code class="text-sm bg-slate-100 sm:hidden">:ver</code><code class="text-sm bg-slate-100 hidden sm:inline">:version</code></span> is the version of the package</li><li><code class="text-sm bg-slate-100">:file</code> is the path to a file in the package</li></ul><p class="mt-4">For example:</p><ul class="mt-4 ml-6 list-disc list-outside"><li class="marker:pr-2"><a class="text-blue-600 hover:underline break-all" href="/preact@10.26.4/dist/preact.min.js">unpkg.com/preact@10.26.4/dist/preact.min.js</a></li><li class="marker:pr-2"><a class="text-blue-600 hover:underline break-all" href="/react@18.3.1/umd/react.production.min.js">unpkg.com/react@18.3.1/umd/react.production.min.js</a></li><li class="marker:pr-2"><a class="text-blue-600 hover:underline break-all" href="/three@0.174.0/build/three.module.min.js">unpkg.com/three@0.174.0/build/three.module.min.js</a></li></ul><p class="mt-4">You can also use any valid <a class="text-blue-600 hover:underline" href="https://docs.npmjs.com/about-semantic-versioning">semver</a> range or <a class="text-blue-600 hover:underline" href="https://docs.npmjs.com/adding-dist-tags-to-packages">npm tag</a>:</p><ul class="mt-4 ml-6 list-disc list-outside"><li class="marker:pr-2"><a class="text-blue-600 hover:underline break-all" href="/preact@latest/dist/preact.min.js">unpkg.com/preact@latest/dist/preact.min.js</a></li><li class="marker:pr-2"><a class="text-blue-600 hover:underline break-all" href="/react@^18/umd/react.production.min.js">unpkg.com/react@^18/umd/react.production.min.js</a></li></ul><p class="mt-4">If you don't specify a version, the <code class="text-sm bg-slate-100">latest</code> tag is used by default.</p><ul class="mt-4 ml-6 list-disc list-outside"><li><a class="text-blue-600 hover:underline break-all" href="/preact/dist/preact.min.js">unpkg.com/preact/dist/preact.min.js</a></li><li><a class="text-blue-600 hover:underline break-all" href="/vue/dist/vue.esm-browser.prod.js">unpkg.com/vue/dist/vue.esm-browser.prod.js</a></li></ul><p class="mt-4">Add a trailing <code class="text-sm bg-slate-100">/</code> to a directory URL to view a listing of all the files in that directory.</p><ul class="mt-4 ml-6 list-disc list-outside"><li class="marker:pr-2"><a class="text-blue-600 hover:underline" href="/react/">unpkg.com/react/</a></li><li class="marker:pr-2"><a class="text-blue-600 hover:underline" href="/preact/src/">unpkg.com/preact/src/</a></li><li><a class="text-blue-600 hover:underline" href="/react-router/">unpkg.com/react-router/</a></li></ul><p class="mt-4">If you'd like to browse an older version of a package, include a version number in the URL.</p><ul class="mt-4 ml-6 list-disc list-outside"><li class="marker:pr-2"><a class="text-blue-600 hover:underline" href="/react@18/">unpkg.com/react@18/</a></li><li><a class="text-blue-600 hover:underline" href="/react-router@5/">unpkg.com/react-router@5/</a></li></ul><p class="mt-4">If you don't specify a file path, UNPKG will resolve the file based on the package's default <a class="text-blue-600 hover:underline" href="https://nodejs.org/api/packages.html#package-entry-points">entry point</a>. In many packages that are meant solely for frontend development, like jQuery and GSAP, this will be the value of <a class="text-blue-600 hover:underline" href="https://nodejs.org/api/packages.html#main">the <code class="text-sm bg-slate-100">main</code> field</a> in the <code class="text-sm bg-slate-100">package.json</code> file.</p><ul class="mt-4 ml-6 list-disc list-outside"><li class="marker:pr-2"><a class="text-blue-600 hover:underline" href="/jquery">unpkg.com/jquery</a></li><li class="marker:pr-2"><a class="text-blue-600 hover:underline" href="/gsap">unpkg.com/gsap</a></li></ul><p class="mt-4">In modern packages that use <a class="text-blue-600 hover:underline" href="https://nodejs.org/api/packages.html#exports">the <code class="text-sm bg-slate-100">exports</code> field</a>, UNPKG will resolve the file using the <code class="text-sm bg-slate-100">default</code> <a class="text-blue-600 hover:underline" href="https://nodejs.org/api/packages.html#conditional-exports">export condition</a>.</p><p class="mt-4">So, for example if you publish a package with the following <code class="text-sm bg-slate-100">package.json</code>:</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;"><span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;name&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;my-package&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;exports&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;default&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;./dist/index.js&quot;</span>
  <span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span></div></div><p class="mt-8">You would be able to load your package from UNPKG using a <code class="text-sm bg-slate-100">&lt;script></code> tag like:</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://unpkg.com/my-package&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></div></div><p class="mt-8">The full <code class="text-sm bg-slate-100">exports</code> spec is supported, including subpaths. So if your <code class="text-sm bg-slate-100">package.json</code> looks like:</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;"><span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;name&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;my-package&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;exports&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;./exp&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">&quot;default&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;./dist/exp.js&quot;</span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span></div></div><p class="mt-8">You can load the <code class="text-sm bg-slate-100">exp</code> subpath with:</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://unpkg.com/my-package/exp&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></div></div><p class="mt-8">Custom export conditions are supported via the <code class="text-sm bg-slate-100">?conditions</code> query parameter. This allows you to load a different file based on the environment or other conditions. For example, to fetch React using the <code class="text-sm bg-slate-100">react-server</code> condition, you could do:</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;"><span class="hljs-built_in">fetch</span>(&quot;https://unpkg.com/react?conditions=react-server&quot;)</div></div><p class="mt-8">If you'd like to specify a custom build of your package that should be used as the default entry point on UNPKG, you can use either the <code class="text-sm bg-slate-100">unpkg</code> field in your <code class="text-sm bg-slate-100">package.json</code> or the <code class="text-sm bg-slate-100">unpkg</code> export condition in your <code class="text-sm bg-slate-100">exports</code> field.</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;"><span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;name&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;my-package&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;unpkg&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;./dist/index.unpkg.js&quot;</span><span class="hljs-punctuation">,</span> <span class="hljs-comment">// This works</span>
  <span class="hljs-attr">&quot;exports&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;unpkg&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;./dist/index.unpkg.js&quot;</span> <span class="hljs-comment">// This works, too</span>
    <span class="hljs-attr">&quot;default&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;./dist/index.js&quot;</span>
  <span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span></div></div></section><section id="nobuild-apps"><h2 class="mt-16 mb-8 text-lg font-semibold group">Nobuild Apps <a class="outline-none after:content-['#'] after:ml-1 after:text-slate-300 after:opacity-0 group-hover:after:opacity-100 after:transition-opacity" href="#nobuild-apps"></a></h2><p class="mt-4">UNPKG is ideal for loading dependencies in apps that run entirely in the browser without a build step. You can load <a class="text-blue-600 hover:underline" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">JavaScript modules</a> from UNPKG directly in your HTML using an <a class="text-blue-600 hover:underline" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap">import map</a>.</p><p class="mt-4">Below is a fully functional Preact app that does not require a build in order to run.</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;"><span class="hljs-meta">&lt;!doctype <span class="hljs-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span> /&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;importmap&quot;</span>&gt;</span><span class="language-javascript">
      {
        <span class="hljs-string">&quot;imports&quot;</span>: {
          <span class="hljs-string">&quot;preact&quot;</span>: <span class="hljs-string">&quot;https://unpkg.com/preact@10.25.4/dist/preact.module.js&quot;</span>,
          <span class="hljs-string">&quot;preact/hooks&quot;</span>: <span class="hljs-string">&quot;https://unpkg.com/preact@10.25.4/hooks/dist/hooks.module.js&quot;</span>,
          <span class="hljs-string">&quot;htm&quot;</span>: <span class="hljs-string">&quot;https://unpkg.com/htm@3.1.1/dist/htm.module.js&quot;</span>
        }
      }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;module&quot;</span>&gt;</span><span class="language-javascript">
      <span class="hljs-keyword">import</span> { h, render } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;preact&quot;</span>;
      <span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;preact/hooks&quot;</span>;
      <span class="hljs-keyword">import</span> htm <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;htm&quot;</span>;

      <span class="hljs-keyword">const</span> html = htm.<span class="hljs-title function_">bind</span>(h);

      <span class="hljs-keyword">function</span> <span class="hljs-title function_">App</span>(<span class="hljs-params"></span>) {
        <span class="hljs-keyword">let</span> [count, setCount] = <span class="hljs-title function_">useState</span>(<span class="hljs-number">0</span>);

        <span class="hljs-keyword">return</span> html`<span class="language-xml">
          <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Count: </span><span class="hljs-subst">${count}</span><span class="language-xml"><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=</span></span><span class="hljs-subst">${() =&gt; setCount(count + <span class="hljs-number">1</span>)}</span><span class="language-xml"><span class="hljs-tag">&gt;</span>Increment<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        `</span>;
      }

      <span class="hljs-title function_">render</span>(html`<span class="language-xml">&lt;</span><span class="hljs-subst">${App}</span><span class="language-xml"> /&gt;`</span>, <span class="hljs-variable language_">document</span>.<span class="hljs-property">body</span>);
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span></div></div><p class="mt-8">No bundler required! This is ideal for small projects, prototypes, or any situation where you'd like to get something up and running quickly without setting up a build pipeline.</p></section><section id="metadata-api"><h2 class="mt-16 mb-8 text-lg font-semibold group">Metadata API <a class="outline-none after:content-['#'] after:ml-1 after:text-slate-300 after:opacity-0 group-hover:after:opacity-100 after:transition-opacity" href="#metadata-api"></a></h2><p class="mt-4">UNPKG serves metadata about the files in a package when you append <code class="text-sm bg-slate-100">?meta</code> to any package root or subdirectory URL.</p><p class="mt-4">For example:</p><ul class="mt-4 ml-6 list-disc list-outside"><li><a class="text-blue-600 hover:underline" href="/react-router@7.3.0/?meta">unpkg.com/react-router@7.3.0/?meta</a></li><li><a class="text-blue-600 hover:underline" href="/react-router@7.3.0/dist/?meta">unpkg.com/react-router@7.3.0/dist/?meta</a></li></ul><p class="mt-4">This will return a JSON object with information about the files in that directory, including path, size, type, and <a class="text-blue-600 hover:underline" href="https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity">subresource integrity</a> value.</p><div class="mt-8"><div class="p-4 font-mono text-sm leading-6 bg-white border border-slate-300 whitespace-pre overflow-x-auto" style="tab-size:2;">{
  package: <span class="hljs-string">&quot;react-router&quot;</span>,
  version: <span class="hljs-string">&quot;7.3.0&quot;</span>,
  prefix: <span class="hljs-string">&quot;/dist/&quot;</span>,
  files: [
    {
      <span class="hljs-selector-tag">path</span>: <span class="hljs-string">&quot;/dist/development/dom-export.js&quot;</span>,
      size: <span class="hljs-number">195045</span>,
      type: <span class="hljs-string">&quot;text/javascript&quot;</span>,
      integrity: <span class="hljs-string">&quot;sha256-z5j8OHOsGkvfGAjBtW8sbj+M68LLmgLTSjDHk4A5uYA=&quot;</span>
    },
    {
      <span class="hljs-selector-tag">path</span>: <span class="hljs-string">&quot;/dist/production/dom-export.js&quot;</span>,
      size: <span class="hljs-number">195047</span>,
      type: <span class="hljs-string">&quot;text/javascript&quot;</span>,
      integrity: <span class="hljs-string">&quot;sha256-Gh8wMHW9MO5IMaBq7fOc7szDMRemnO/7Qr8kTK4ebgY=&quot;</span>
    },
    // ...
  ]
}</div></div></section><section id="cache-performance"><h2 class="mt-16 mb-8 text-lg font-semibold group">Cache Performance <a class="outline-none after:content-['#'] after:ml-1 after:text-slate-300 after:opacity-0 group-hover:after:opacity-100 after:transition-opacity" href="#cache-performance"></a></h2><p class="mt-2">UNPKG is a mirror of everything on npm. Every file on npm is automatically available on unpkg.com within minutes of being published.</p><p class="mt-2">Additionally, UNPKG runs on <a class="text-blue-600 hover:underline" href="https://www.cloudflare.com">Cloudflare's</a> global edge network using <a class="text-blue-600 hover:underline" href="https://workers.cloudflare.com/">Cloudflare Workers</a>, which allow UNPKG to serve billions of requests every day with low latency from hundreds of locations worldwide. The &quot;serverless&quot; nature of Cloudflare Workers also allows UNPKG to scale immediately to satisfy sudden spikes in traffic.</p><p class="mt-2">Files are cached on Cloudflare's global content-delivery network 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.</p><p class="mt-2">URLs that do not specify a fully resolved package version number redirect to one that does. This is the <code class="text-sm bg-slate-100">latest</code> version when none is specified, or the maximum satisfying version when a semver range is given. <span class="font-semibold">For the best chance of getting a cache hit, use the full package version number and file path in your UNPKG URLs instead of an npm tag or semver range</span>.</p><p class="mt-2">For example, a URL like <a class="text-blue-600 hover:underline" href="/preact@10">unpkg.com/preact@10</a> will not be a direct cache hit because UNPKG needs to resolve the version <code class="text-sm bg-slate-100">10</code> to the latest matching version of Preact published with that major, plus it needs to figure out which file to serve. So a short URL like this will always cause a redirect to the permanent URL for that resource. If you need to make sure you hit the cache, use a fixed version number and the full file path, like <a class="text-blue-600 hover:underline break-all" href="/preact@10.5.0/dist/preact.min.js">unpkg.com/preact@10.5.0/dist/preact.min.js</a>.</p></section><section id="about"><h2 class="mt-16 mb-8 text-lg font-semibold group">About <a class="outline-none after:content-['#'] after:ml-1 after:text-slate-300 after:opacity-0 group-hover:after:opacity-100 after:transition-opacity" href="#about"></a></h2><p class="mt-2">UNPKG is an <a class="text-blue-600 hover:underline" href="https://github.com/unpkg" title="UNPKG on GitHub">open source project</a> from <a class="text-blue-600 hover:underline" href="https://x.com/mjackson" title="mjackson on X">@mjackson</a>. UNPKG is not affiliated with or supported by npm in any way. Please do not contact npm for help with UNPKG. Instead, please reach out to <a class="text-blue-600 hover:underline" href="https://x.com/unpkg" title="UNPKG on X">@unpkg</a> with any questions or concerns.</p></section></div><div class="hidden xl:block absolute h-full w-48 top-0 -right-52"><div class="sticky top-12"><div data-hydrate="{&quot;key&quot;:&quot;HomeNav&quot;,&quot;props&quot;:{&quot;items&quot;:{&quot;overview&quot;:&quot;Overview&quot;,&quot;nobuild-apps&quot;:&quot;Nobuild Apps&quot;,&quot;metadata-api&quot;:&quot;Metadata API&quot;,&quot;cache-performance&quot;:&quot;Cache Performance&quot;,&quot;about&quot;:&quot;About&quot;}}}"><nav class="relative border-l-1 border-gray-300 text-slate-600"><div class="absolute w-1 h-6.5 transition-all duration-300 bg-gray-600" style="top:0px;"></div><ol><li id="overview-nav-item" class="my-2 pl-8"><a href="#overview">Overview</a></li><li id="nobuild-apps-nav-item" class="my-2 pl-8"><a href="#nobuild-apps">Nobuild Apps</a></li><li id="metadata-api-nav-item" class="my-2 pl-8"><a href="#metadata-api">Metadata API</a></li><li id="cache-performance-nav-item" class="my-2 pl-8"><a href="#cache-performance">Cache Performance</a></li><li id="about-nav-item" class="my-2 pl-8"><a href="#about">About</a></li></ol></nav></div></div></div></div></main></body></html>