The Deno Standard Library is now available on JSR
We are excited to announce a significant evolution in the Deno ecosystem: the Deno Standard Library, a robust collection of high-quality TypeScript packages, has officially moved to JSR, the new JavaScript package registry.
Since the early days of Deno, the Standard Library has been a cornerstone at https://deno.land/std, featuring essential packages ranging from file system management to advanced cryptographic functions. These packages are all audited by the Deno team and guaranteed to work with Deno.
JSR is not another package manager; it’s a forward-thinking registry designed to unify and simplify JavaScript package distribution across different environments. Built to seamlessly integrate with Deno and other JavaScript runtimes, JSR introduces a number of features that significantly enhance the JavaScript ecosystem. Its compatibility extends to environments like Node.js, Cloudflare Workers, and even browsers using bundlers, ensuring a broad spectrum of JavaScript applications can leverage Deno’s Standard Library.
With the transition to https://jsr.io/@std, JSR now hosts the Standard Library, providing autogenerated documentation and SemVer deduplication while enhancing accessibility and versatility for developers worldwide.
Using the Standard Library on JSR
To install the packages, use the following command:
deno add @std/fs @std/path
This command updates your
deno.json
import map
as shown below:
{
"imports": {
"@std/fs": "jsr:@std/fs@^0.224.0",
"@std/path": "jsr:@std/path@^0.224.0"
}
}
You can then import these packages in your source code:
import { copy } from "@std/fs";
import { join } from "@std/path";
await copy("foo.txt", join("dist", "foo.txt"));
// Copies foo.txt to dist/foo.txt
Alternatively, you can import directly using a jsr:
specifier:
// This works without import map
import { copy } from "jsr:@std/fs@^0.224.0";
import { join } from "jsr:@std/path@^0.224.0";
await copy("foo.txt", join("dist", "foo.txt"));
Node.js and beyond
JSR’s compatibility with npm allows you to use the Deno Standard Library in Node.js, Cloudflare Workers, and browsers with bundlers. For example, running this command
npx jsr add @std/async @std/collections
will add dependencies to your package.json
:
{
"dependencies": {
+ "@std/async": "npm:@jsr/std__async@^0.224.0",
+ "@std/collections": "npm:@jsr/std__collections@^0.224.0"
}
}
You can now use these packages as shown below:
import { delay } from "@std/async";
import { deepMerge } from "@std/collections";
await delay(100);
console.log(deepMerge({ foo: { bar: 1 }, baz: 2 }, { foo: { qux: 2 } }));
Run this script with Node.js:
$ node main.mjs
{ foo: { bar: 1, qux: 2 }, baz: 2 }
Currently, about 70% of the Standard Library packages are compatible with Node.js. You can look at the compatibility icons in the package list on https://jsr.io/@std to see which packages are compatible with Node.js.
Note: The Standard Library is only distributed as ES Modules. Any script that uses the Standard Library needs to be an ES Module. This means your files either need to have the
.mjs
file extension, or the project’spackage.json
needs to have a"type": "module"
property.
Independent versioning for each Standard Library package
The Deno Standard Library is now organized into 37 distinct packages, such as
@std/fs
and @std/path
.
The decision to version different parts of the Standard Library individually was
driven by the varied maturity, complexity, and usage of its components. Some
parts of the library, like @std/fs
, are mature and undergo fewer changes,
already being widely used in numerous real-world applications. In contrast,
newer additions, such as @std/expect
—which is
only four months old—are still in the early stages of adoption and development.
Previously, the diverse maturity levels within the Standard Library posed a significant challenge to its stabilization. It was impractical to apply a one-size-fits-all approach to the entire library, given the broad spectrum of maturity across its components.
By adopting independent versioning for each package, we can stabilize mature packages promptly while continuing to refine and experiment with the less mature ones. This strategy not only accelerates the stabilization of the standard library but also maintains the flexibility needed to evolve it further.
workspaces
Leveraging Deno We manage interdependencies among @std
packages using Deno’s brand new
workspaces feature. This feature helps packages depend on each other locally
without needing to publish each one.
The workspaces
feature is still under development. In particular, LSP support
for it is still to be added. If you’re interested in its development progress,
check out and subscribe to
the tracking issue.
The workspaces
feature is enabled by defining the "workspaces"
field in
deno.json
. Let’s take a look at the
deno.json
of the Standard Library repository:
{
"workspaces": [
"./archive",
"./assert",
"./async",
"./bytes"
// ...
]
}
Notice that, for example, @std/archive
depends on @std/assert
(ref):
import { assert } from "@std/assert/assert";
...
assert(fileSize !== undefined, "fileSize must be set");
...
The assert
function is directly imported from the local ./assert
directory
in the repository instead of the published version. The Standard Library still
works like a single source code despite each of the packages being published
independently.
deno.land/std
Future of deno.land/std
will still be available indefinitely.
All programs that depend on deno.land/std
will keep working. Don’t worry!
However, going forward new features will be published to
jsr.io/@std. deno.land/std
will receive only critical
updates, such as security patches.
deno.land/std
to jsr:@std
Migrating from If you currently use the Standard Library from deno.land/std
, we recommend you
upgrade to importing from jsr:@std
.
To upgrade to jsr:@std
, we first recommend upgrading your deno.land/std
version to 0.224.0
:
- import { join } from "https://deno.land/[email protected]/path/mod.ts";
+ import { join } from "https://deno.land/[email protected]/path/mod.ts";
Then update the HTTP specifier to the JSR specifier:
- import { join } from "https://deno.land/[email protected]/path/mod.ts";
+ import { join } from "jsr:@std/[email protected]";
That’s it!
Looking ahead
The Standard Library is still at v0.x versions, which means that the APIs are
not yet stabilized. We plan to stabilize the Deno Standard Library on a
package-by-package basis. The first candidates for stabilization are
@std/bytes
and
@std/collections
. For
updates, follow
this issue (denoland/deno_std#4600).
As we move forward, we’re excited about the possibilities that JSR opens up for developers across the globe. Join us in embracing this new phase in JavaScript development.