JSR – Next Generation JavaScript Registry

Rate this content
Bookmark

JSR, a modern package registry for JavaScript and TypeScript, is designed to be fast, simple, reliable, and work across many JavaScript runtimes. Come learn how using JSR can simplify your developer experience.

This talk has been presented at JSNation 2024, check out the latest edition of this JavaScript Conference.

FAQ

JSR is a new JavaScript registry, similar to npm, that supports TypeScript out of the box. It generates the necessary files for TypeScript without requiring the setup of TSC.

No, JSR does not replace npm. It is built on top of npm and is compatible with npm packages.

JSR is compatible with different runtimes such as Node, Deano, and Cloudflare workers, as long as they support Node modules.

Yes, you can use other package managers like npm, pnpm, and yarn with JSR, as long as they support Node modules.

JSR was created due to the complexity of npm and its lack of TypeScript support. It aims to provide an alternative that embraces TypeScript and offers additional features.

JSR offers GitHub Action integration, provenance attestations, and automatic documentation generation for APIs.

JSR integrates with GitHub Actions via YDC tokens, allowing you to run 'npm JSR publish' without needing to manually input authentication tokens.

Provenance attestation in JSR proves that you published a package and are the real author, preventing man-in-the-middle attacks and stolen tokens.

JSR automatically generates documentation for all your APIs, eliminating the need to set up tools like TS docs.

To publish a package with JSR, you need to create a JSR.json file with the package details and run 'npx JSR publish'. The system will handle the rest, including authorization and documentation generation.

Leo Kettmeir
Leo Kettmeir
6 min
13 Jun, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

JSR is a new JavaScript registry that supports TypeScript and offers additional features like GitHub Action integration, provenance attestations, and documentation generation. It provides a simple website with package search, documentation, and a gamified score. The process of publishing a new package in JSR involves creating a JSR.json file with package details and exports, using MPX JSR publish to publish the package, and approving authorization in the browser. However, documentation for the package is not automatically generated and needs to be manually added.

1. Introducing JSR and its Features

Short description:

Today, I will be introducing JSR once again. It's a new JavaScript registry, similar to npm, but it supports TypeScript out of the box. We created JSR due to the complexity of npm. Npm is not innovating at all. We have additional features like GitHub Action integration, provenance attestations, and documentation generation. Let's take a look at JSR itself, a simple website with package search, documentation, and a gamified score. Let's publish a package.

Today, I will be introducing JSR once again. I'm Leo, I work at Deano, I work on JSR, documentation generation and web APIs.

What is JSR? It's a new JavaScript registry, similar to npm, but it supports TypeScript out of the box. No setting up TSC, you upload TypeScript and it generates the files for you. It does not replace npm, however. It's built on top of it. You can still use npm packages alongside it. It's compatible across different run times, be it Node, Deano, Cloudflare workers, as long as they support Node modules, it works. Same goes for package managers, npm, pm, pm, yarn, and more. As long as you support Node modules, it will just work.

So why did we create JSR? It's due to the complexity of npm. As said, TypeScript is getting complicated, but everyone uses TypeScript nowadays, so why does not npm embrace it? The solution was, let's create an alternative built on top of it. Npm is not innovating at all. No TypeScript support, made very little changes, and seems more going for an enterprise route, but nothing for the open-source ecosystem. Our values are that JavaScript is one that progresses rapidly, and, again, npm doesn't really. The reason we created this is because npm is not advancing.

Some additional features of npm is that we have GitHub Action integration directly, so via YDC tokens, you can run npm JSR publish and it will just publish. You don't need to put any tokens, it just authenticates that it is actually you. We have provenance attestations which, if using GitHub Actions, it will generate provenance for you which further proves that you published the package and that you are the real author and not that there is some man in the middle of some sort of stolen tokens, et cetera. Documentation generation is that JSR generates documentation for all your APIs directly for you. You don't need to set up TS docs or some other documentation generation tool. It does it straight for you.

So, demo time. This is going to be interesting. Let's take a look at JSR itself. It's a simple website. We can look for a package, make it bigger, and it's a popular middleware package similar to express from the npm ecosystem. It has a readme, I can click over to the docs, it has some exported types, classes, interfaces, et cetera, and some more documentation, the type parameters, properties, methods, all different information that one would need from a package is included. We also have a neat little score because people love to gamify things. Let's publish a package, shall we? So we're here, an empty directory, nothing fancy to see, and we will just create, actually, let's go to the browser, let me sign in quickly.

2. Publishing a New Package in JSR

Short description:

Let's publish a new package in JSR. Create a JSR.json file with package details and exports. Export a function that prints a welcome message. Use MPX JSR publish to publish the package. Approve authorization in the browser. The package is published, but no documentation is found. The hello function can be found in the actual docs.

And let's go to the main page, and let's publish a new package. So I'm going to select my own scope, or you can create a new one if you want, but I already have mine. And let's just create JS nation, and it's available. Great. So, how to publish? We will just copy this JSR.json, or you can also manually specify the file you want, the config file, but for now, we just create JSR.json, and that contains the name of the package, including the scope, because in JSR everything is scoped, we have the version and the exports. For this example, let's just call this index.ts. This could be an object, key by value, and the key that you want to map to, and let's create a TypeScript file, index, and let's export a function. Hello. Why not? And it takes a year. That's a number. And we just console.log hello JS nation, and let's pass that year. Let's add some documentation as well. So we have the actual function body that is generates a welcome message. Let's say prints. Prints a welcome message, and a year, the year to welcome for. All right, then.

Let's just MPX JSR publish, and let's hope that it works. First has to download the JSR itself, and it opens up the browser to approve the authorisation because there are no tokens passed with the CLI itself. And we approve. It does some magic behind the scenes. And it published. Now it says no documentation found because we didn't add a readme of any sort, but if I go to the actual docs, and go to the hello function on the default export, we have prints a welcome message with the year, specifying the type, and the comment we left earlier, and it returns nothing, obviously. Yes, that's pretty much it.

Thank you very much.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

React's Most Useful Types
React Day Berlin 2023React Day Berlin 2023
21 min
React's Most Useful Types
Top Content
Watch video: React's Most Useful Types
Today's Talk focuses on React's best types and JSX. It covers the types of JSX and React components, including React.fc and React.reactnode. The discussion also explores JSX intrinsic elements and react.component props, highlighting their differences and use cases. The Talk concludes with insights on using React.componentType and passing components, as well as utilizing the react.element ref type for external libraries like React-Select.
The Future of Performance Tooling
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Today's Talk discusses the future of performance tooling, focusing on user-centric, actionable, and contextual approaches. The introduction highlights Adi Osmani's expertise in performance tools and his passion for DevTools features. The Talk explores the integration of user flows into DevTools and Lighthouse, enabling performance measurement and optimization. It also showcases the import/export feature for user flows and the collaboration potential with Lighthouse. The Talk further delves into the use of flows with other tools like web page test and Cypress, offering cross-browser testing capabilities. The actionable aspect emphasizes the importance of metrics like Interaction to Next Paint and Total Blocking Time, as well as the improvements in Lighthouse and performance debugging tools. Lastly, the Talk emphasizes the iterative nature of performance improvement and the user-centric, actionable, and contextual future of performance tooling.
TypeScript and React: Secrets of a Happy Marriage
React Advanced Conference 2022React Advanced Conference 2022
21 min
TypeScript and React: Secrets of a Happy Marriage
Top Content
React and TypeScript have a strong relationship, with TypeScript offering benefits like better type checking and contract enforcement. Failing early and failing hard is important in software development to catch errors and debug effectively. TypeScript provides early detection of errors and ensures data accuracy in components and hooks. It offers superior type safety but can become complex as the codebase grows. Using union types in props can resolve errors and address dependencies. Dynamic communication and type contracts can be achieved through generics. Understanding React's built-in types and hooks like useState and useRef is crucial for leveraging their functionality.
Making Magic: Building a TypeScript-First Framework
TypeScript Congress 2023TypeScript Congress 2023
31 min
Making Magic: Building a TypeScript-First Framework
Top Content
Daniel Rowe discusses building a TypeScript-first framework at TypeScript Congress and shares his involvement in various projects. Nuxt is a progressive framework built on Vue.js, aiming to reduce friction and distraction for developers. It leverages TypeScript for inference and aims to be the source of truth for projects. Nuxt provides type safety and extensibility through integration with TypeScript. Migrating to TypeScript offers long-term maintenance benefits and can uncover hidden bugs. Nuxt focuses on improving existing tools and finds inspiration in frameworks like TRPC.
Stop Writing Your Routes
Vue.js London 2023Vue.js London 2023
30 min
Stop Writing Your Routes
Designing APIs is a challenge, and it's important to consider the language used and different versions of the API. API ergonomics focus on ease of use and trade-offs. Routing is a misunderstood aspect of API design, and file-based routing can simplify it. Unplugging View Router provides typed routes and eliminates the need to pass routes when creating the router. Data loading and handling can be improved with data loaders and predictable routes. Handling protected routes and index and ID files are also discussed.
Faster TypeScript builds with --isolatedDeclarations
TypeScript Congress 2023TypeScript Congress 2023
24 min
Faster TypeScript builds with --isolatedDeclarations
Top Content
This talk discusses the performance issues in TypeScript builds and introduces a new feature called isolated declarations. By running the compiler in parallel and using isolated modules, significant performance gains can be achieved. Isolated declarations improve build speed, compatibility with other tools, and require developers to write types in code. This feature has the potential to further increase performance and may be available in TypeScript soon.

Workshops on related topic

React, TypeScript, and TDD
React Advanced Conference 2021React Advanced Conference 2021
174 min
React, TypeScript, and TDD
Top Content
Featured WorkshopFree
Paul Everitt
Paul Everitt
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.
Mastering advanced concepts in TypeScript
React Summit US 2023React Summit US 2023
132 min
Mastering advanced concepts in TypeScript
Top Content
Featured WorkshopFree
Jiri Lojda
Jiri Lojda
TypeScript is not just types and interfaces. Join this workshop to master more advanced features of TypeScript that will make your code bullet-proof. We will cover conditional types and infer notation, template strings and how to map over union types and object/array properties. Each topic will be demonstrated on a sample application that was written with basic types or no types at all and we will together improve the code so you get more familiar with each feature and can bring this new knowledge directly into your projects.
You will learn:- - What are conditional types and infer notation- What are template strings- How to map over union types and object/array properties.
Deep TypeScript Tips & Tricks
Node Congress 2024Node Congress 2024
83 min
Deep TypeScript Tips & Tricks
Top Content
Featured Workshop
Josh Goldberg
Josh Goldberg
TypeScript has a powerful type system with all sorts of fancy features for representing wild and wacky JavaScript states. But the syntax to do so isn't always straightforward, and the error messages aren't always precise in telling you what's wrong. Let's dive into how many of TypeScript's more powerful features really work, what kinds of real-world problems they solve, and how to wrestle the type system into submission so you can write truly excellent TypeScript code.
Best Practices and Advanced TypeScript Tips for React Developers
React Advanced Conference 2022React Advanced Conference 2022
148 min
Best Practices and Advanced TypeScript Tips for React Developers
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
Are you a React developer trying to get the most benefits from TypeScript? Then this is the workshop for you.In this interactive workshop, we will start at the basics and examine the pros and cons of different ways you can declare React components using TypeScript. After that we will move to more advanced concepts where we will go beyond the strict setting of TypeScript. You will learn when to use types like any, unknown and never. We will explore the use of type predicates, guards and exhaustive checking. You will learn about the built-in mapped types as well as how to create your own new type map utilities. And we will start programming in the TypeScript type system using conditional types and type inferring.
Building Your Own Custom Type System
React Summit 2024React Summit 2024
38 min
Building Your Own Custom Type System
Featured Workshop
Kunal Dubey
Kunal Dubey
I'll introduce the audience to a concept where they can have end-to-end type systems that helps ensure typesafety across the teams Such a system not only improves communication between teams but also helps teams collaborate effectively and ship way faster than they used to before. By having a custom type system, teams can also identify the errors and modify the API contracts on their IDE, which contributes to a better Developer Experience. The workshop would primarily leverage TS to showcase the concept and use tools like OpenAPI to generate the typesystem on the client side. 
Frictionless Development With Unified Type System
JSNation 2024JSNation 2024
113 min
Frictionless Development With Unified Type System
Featured Workshop
Ejiro Asiuwhu
Ejiro Asiuwhu
Imagine developing where frontend and backend sing in harmony, types dance in perfect sync, and errors become a distant memory. That's the magic of TypeScript Nirvana!
Join me on a journey to unveil the secrets of unified type definitions, the key to unlocking frictionless development. We'll dive into:
- Shared language, shared love: Define types once, share them everywhere. Consistency becomes your BFF, errors your worst nightmare (one you'll rarely see).- Effortless coding: Ditch the manual grind of type checking. TypeScript's got your back, freeing you to focus on building awesomeness.- Maintainability magic: With crystal-clear types guiding your code, maintaining it becomes a walk in the park. More time innovating, less time debugging.- Security fortress: TypeScript's type system shields your app from common vulnerabilities, making it a fortress against security threats.