Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

A fast, global content delivery network for NPM packages with ES Module format.

Import from URL

import React from ""

You may also use a semver or a dist-tag instead of a fixed version number, or omit the version/tag entirely to use the latest tag:

import React from ""      // 18.2.0 (latest)
import React from ""   // 17.0.2
import React from "" // 18.3.0-next-3de926449-20220927


import { renderToString } from ""

or import non-module(js) files:

import "" assert { type: "json" }

Specify Dependencies

By default, rewrites import specifiers based on the dependencies field of package.json. To specify version of these dependencies, you can add the ?deps=PACKAGE@VERSION query. Separate multiple dependencies with comma: ?deps=react@17.0.2,react-dom@17.0.2.

import React from ""
import useSWR from ""

Specify External Dependencies

You can add the ?external=foo,bar query to specify external dependencies. Since these dependencies are not resolved, you need to use import maps to specify the URL for these dependencies. If you are using Deno, you can use the CLI Script to generate and update the import maps that will resolve the external dependencies automatically.

  "imports": {
    "preact": "",
    "preact-render-to-string": "",

Or you can mark all dependencies as external by adding * prefix before the package name:

  "imports": {
    "preact": "",
    "preact-render-to-string": "*preact-render-to-string@5.2.0",
    "swr": "*swr@1.3.0",
    "react": "",

Import maps supports trailing slash that can not work with URL search params friendly. To fix this issue, provides a special format for import URL that allows you to use query params with trailing slash: change the query prefix ? to & and put it after the package version.

  "imports": {
    "react-dom": "",
    "react-dom/": "",

Aliasing Dependencies

import useSWR from ""

in combination with ?deps:

import useSWR from ""

The origin idea was coming from @lucacasonato.

Tree Shaking

By default bundles module with all export members, you can specify the exports by adding ?exports=foo,bar query. With esbuild tree shaking, you can get a smaller bundle size:

import { __await, __rest } from "" // 7.3KB
import { __await, __rest } from ",__rest" // 489B

This only works with ESM modules, CJS modules are not supported.

Bundle Mode

import { Button } from ""

In bundle mode, all dependencies are bundled into a single JS file except the peer dependencies.

Development Mode

import React from ""

With the ?dev option, builds modules with process.env.NODE_ENV set to "development" or based on the condition development in the exports field of package.json. This is useful for libraries that have different behavior in development and production. For example, React will use a different warning message in development mode.

ESBuild Options

By default, checks the User-Agent header to determine the build target. You can also specify the target by adding ?target, available targets are: es2015 - es2022, esnext, node, and deno.

import React from ""

Other supported options of esbuild:

  • Keep names
    import React from ""
  • Ignore annotations
    import React from ""

Web Worker supports ?worker query to load the module as a web worker:

import workerFactory from ""

const worker = workerFactory()

You can pass some custom code snippet to the worker when calling the factory function:

const workerAddon = `
self.onmessage = function (e) {
const worker = workerFactory(workerAddon)

Package CSS

<link rel="stylesheet" href="">

This only works when the package imports CSS files in JS directly.

Specify CJS Exports

If you get an error like ...not provide an export named..., that means can not resolve CJS exports of the module correctly. You can add ?cjs-exports=foo,bar query to specify the export names:

import { NinetyRing, NinetyRingWithBg } from ",NinetyRingWithBg"

Deno Compatibility resolves the node internal modules (fs, child_process, etc.) with to support Deno.

import postcss from ""
import autoprefixer from ""

const { css } = await postcss([ autoprefixer ]).process(`
  backdrop-filter: blur(5px);
  user-select: none;

By default uses a fixed version of You can add the ?deno-std=$VER query to specify a different version:

import postcss from ""

X-Typescript-Types Header

You may find the X-TypeScript-Types header in response from if the module has a types field in package.json. This allows Deno to automatically download the type definitions for types checking and auto-completion (link).

Figure #1

You can add the ?no-dts query to disable the X-TypeScript-Types header if the types is incorrect:

import unescape from ""

Using CLI Script provides a CLI script to manage the imports with import maps in Deno, it resolves dependencies automatically and always use a pinned build version. To use the CLI script, you need to run the init command in your project root directory:

deno run -A -r init

After initializing, you can use the deno task esm:[add/update/remove] commands to manage imports of NPM in the import maps.

deno task esm:add react react-dom # add packages
deno task esm:add react@17 # add packages with specified version
deno task esm:add react:preact/compat # add packages with alias
deno task esm:update react react-dom # upgrade packages
deno task esm:update # update all packages
deno task esm:remove react react-dom # remove packages

Pinning Build Version

Since we update server frequently, the server will rebuild all modules when a patch pushed, sometimes we may break packages that work well before by mistake. To avoid this, you can pin the build version of a module with the ?pin query, this returns an immutable cached module.

import React from ""

Global CDN

The Global CDN of is provided by Cloudflare, one of the world's largest and fastest cloud network platforms.


To host by yourself, check the hosting documentation.