What is JSR from Deno.js?

The open-source package registry for modern JavaScript and TypeScript. JSR is designed for TypeScript JSR packages are distributed as web-standard ECMAScript modules.

Why is JSR?

JSR is a superset of NPM, much as TypeScript is a superset of JavaScript and was created to improve on the developer experience, performance,readability,and security of NPM.

Native TypeScript support

JSR was designed with TypeScript support in mind. TypeScript, as a superset of JavaScript and test bed for the latest ECMAScript features, has emerged as a default choice for non-trivial JavaScript codebase.

ECMAScript modules only

The web standard for JavaScript modules is ESM. A modern package registry should rally around this standard and shift the community in this direction.

Cross-runtime support

JSR works with Deno and other NPM environments that populate a node_modules. This means that Node.js, Bun, Cloudflare Workers, and other projects that manage dependencies with a package.json can work together with JSR as well. Module authors can count on great editor support from strongly typed modules, without the need to transpile and distribute typings manually.

Outstanding developer experience

  • Easy publishing with a single command.
  • Automatic API documentation generation.
  • Zero-config publishing from GitHub Actions.
  • Automatic inclusion of .d.ts files for Node.js/NPM distribution.
  • Automated guidance on TypeScript best practices.

JSR is designed to be safe, quick, and adaptable, and also work well on devices with limited resources.

Using JSR with Deno

you can add JSR imports using the Deno add command.

deno add jsr:@std/assert

You can then use the module from code like this.

#import * as _std_assert from "@std/assert";
import * as _std_assert from "jsr:@std/assert";

Publish a JSR package

To create a JSR package, you need a mod.ts file in the root repo. The mod.ts tells about what to export.

// mod.ts
import * as chalk from "chalk";

import * as express from "npm:express@4";

After you have written your repo. you have to create a deno.json file. The file contains package metadata like name version and entrypoint(s).

// jsr.json / deno.json
{
  "name": "@luca/greet",
  "version": "1.0.0",
  "exports": "./mod.ts",
  ...
}

At last you you should run command deno publish to publish your package into the JSR.IO.

# deno
deno publish
# npm
npx jsr publish
# yarn
yarn dlx jsr publish
# pnpm
pnpm dlx jsr publish

Was this article helpful to you?
Provide feedback

Last edited on December 26, 2024.
Edit this page