About this project

# esm.sh A no-build JavaScript CDN for modern web development. ## Overview esm.sh allows importing JavaScript modules directly from HTTP URLs without any installation or build steps. It transforms source code into browser-compatible ES modules on the server side, caches the results, and serves them from a global Cloudflare CDN. ## Registry Support - **NPM**: Import any package by name, version, or tag - **JSR**: Deno-friendly registry starting with `/jsr/` - **GitHub**: Direct imports from repositories with `/gh/` prefix - **pkg.pr.new**: Preview builds from PRs with `/pr/` prefix ## Key Features ### Zero-Build Imports ```js import React from "https://esm.sh/react@19.2.4"; import { encodeBase64 } from "https://esm.sh/jsr/@std/encoding@1.0.0/base64"; ``` ### Source Transformation Automatically transforms `.ts(x)`, `.vue`, and `.svelte` files in the browser without build tools. ### Dependency Management Specify dependency versions with query parameters: ```js import useSWR from "https://esm.sh/swr?deps=react@18.3.1"; ``` Alias dependencies: ```js import useSWR from "https://esm.sh/swr?alias=react:preact/compat"; ``` ### Bundling Options - `?bundle=false` - disable default bundling - `?standalone` - bundle all dependencies into a single file - `?raw` - serve untransformed source code - `?exports=foo,bar` - tree-shake to specific exports ### Build Configuration Control build targets and options: ```js // Development build import React from "https://esm.sh/react?dev"; // Specify target import React from "https://esm.sh/react?target=es2022"; // ESBuild options import foo from "https://esm.sh/foo?conditions=custom1,custom2"; import foo from "https://esm.sh/foo?keep-names"; ``` ### Import Maps Integration Works with HTML import maps for bare specifier resolution: ```html <script type="importmap"> { "imports": { "react": "https://esm.sh/react@19.2.4" } } </script> ``` Use `?external` or `*` prefix to keep imports as bare specifiers for browser resolution. ### Additional Features - **CSS imports**: `?css` flag for packages importing CSS in JS - **Web Workers**: `?worker` query for worker loading with injection support - **Deno compatibility**: Resolves Node.js built-in modules (fs, os, net, etc.) - **TypeScript support**: Automatic type definitions via `X-TypeScript-Types` header - **tsx script**: 1KB script for writing TSX directly in HTML ### Cache Purge Refresh cached builds for updated packages: - Exact versions rebuild immediately - Bare names re-resolve versions on next request - Proof-of-work challenge prevents abuse ### Self-Hosting Deploy your own instance following the [hosting documentation](./HOSTING.md). ## Limitations Not currently supported by Node.js or Bun runtimes. ## License MIT