How to publish Deno modules
Tags: deno, javascript, typescript, tutorial
Published: 2020-08-04 19:05:18

So you've just written your first Deno module and now you want to make it available to the community. Here's how you can publish your module to the two most popular Deno registries:

# Deno Land Registry

The main and likely most popular Deno registry is the [official Deno Land registry itself](deno.land/x/). Here's how to add a GitHub repo to the registry:

1. Navigate to the repository you want to add.

1. Go to the Settings tab.

    ![GitHub repository home page with highlighted settings tab](https://dev-to-uploads.s3.amazonaws.com/i/u6ay8kkna5kefgqlu483.png)

1. Click on the Webhooks tab.

    ![GitHub settings page with highlighted webhooks menu option](https://dev-to-uploads.s3.amazonaws.com/i/gck4hdlxnbpjn2wlbb3i.png)

1. Click on the `Add webhook` button.

    ![GitHub webhooks page with highlighted add webhook button](https://dev-to-uploads.s3.amazonaws.com/i/kfq6gpt4h09kzk456bc7.png)

1. Enter the URL `https://api.deno.land/webhook/gh/<moduleName>` in the `Payload URL` field, making sure to replace the `<moduleName>` part with the name of your module.

    ![New webhook page with filled in Payload URL textbox](https://dev-to-uploads.s3.amazonaws.com/i/kdjtpz63t9finpnjlwl2.png)

1. Select `application/json` as the content type.

    ![New webhook page with JSON content type selected](https://dev-to-uploads.s3.amazonaws.com/i/t98llh4u2jd2o8awtput.png)

1. Select the `Let me select individual events` radio button.

    ![New webhook page with individual events option selected](https://dev-to-uploads.s3.amazonaws.com/i/nc69pwyi2pkn4xkxugwj.png)

1. Select only the `Branch or tag creation` checkbox.

    ![New webhook page with branch or tag creation option selected](https://dev-to-uploads.s3.amazonaws.com/i/pxigr8qdz5t71aft69hv.png)

1. Click on the `Add webhook` button.

    ![New webhook page with add webhook button highlighted](https://dev-to-uploads.s3.amazonaws.com/i/urhzvsvjs8dqh2qwbngf.png)

1. Confirm that your webhook has been added on the Webhook screen.

    ![GitHub webhooks page with newly created webhook highlighted in list](https://dev-to-uploads.s3.amazonaws.com/i/ymfrdcftp333syz8r7sk.png)

Once these steps have been completed, all that is left is to create a release / tag in you GitHub repo. Here's one way you can create a release in GitHub:

1. Navigate to the repository you want to create a release for.

1. Click on the `Releases` link on the right hand side menu.

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bxq2ps0eok818dn813ve.png)

1. Click on the `Draft a new release` button.

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zya5w6dt5cmdbwh7be29.png)

1. Fill out the `Tag version` field, `Release title` field and `Describe this release` textbox.

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q7anqfvu9dxuvhydcn88.png)

1. Click on the `Publish release` button.

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gchlcyr80pvfd8eqxj12.png)

You should now be able to navigate to <https://deno.land/x/> and search for your module, or navigate directly to your hosted module via `https://deno.land/x/<moduleName>`, again replacing `<moduleName>` with the name of your module. If it doesn't appear at first, try refreshing a couple of times - the registration and upload of a new module and tag can take a few seconds some times.

If after some time your module is still not appearing in the Deno registry some good things to try are:

1. Navigate to your repo's Releases page and check that you successfully created the release.
1. Navigate to your Webhooks settings page and check that you created the webhook exactly as described - clicking `Edit` or on the webhook link will take you to a page where you can edit your webhook.
1. On the webhook edit page, navigate to the `Recent Deliveries` section at the bottom and click on the last on the delivery ids to expand out detailed information on the recent webhook requests and responses which can be useful for debugging.
1. If all else fails, reach out to the Deno maintainers either by opening an issue on the [deno_registry2](https://github.com/denoland/deno_registry2) repository or by messaging on the [#help channel of the Deno Discord](https://discord.com/invite/deno).

For more information about the Deno registry, head over to it's landing page at <https://deno.land/x/> (which also has usage guides) and check out [this blog post on the v2 registry](https://deno.land/posts/registry2).

# nest.land Registry

Another popular registry is the [nest.land registry](https://nest.land/), a Deno registry on the blockchain. This registry has several nice features around security, immutability and being independent of any source code management system, i.e. it doesn't require you to be using [git](https://git-scm.com/) or [GitHub](https://github.com/).

Here's how you can upload to the nest.land registry:

1. Navigate to the <https://nest.land/> page in a browser.

1. Click on the `Get Started` link.

    ![nest.land homepage with get started link highlighted](https://dev-to-uploads.s3.amazonaws.com/i/59s4odmx3iq5jfd2ov46.png)

1. Click on the `No account? Sign up` link.

    ![nest.land page with sign up link highlighted](https://dev-to-uploads.s3.amazonaws.com/i/f31jjrjeyehnq10xrvvi.png)

1. Fill out the `Username` field with a new, unique username for your account and enter a secret password into the `Password` and `Confirm Password` fields.

    ![nest.land page with username and password fields highlighted](https://dev-to-uploads.s3.amazonaws.com/i/n09gg6ear9p8ire6v5gp.png)

1. Click on the `Create Account and Generate an API Key` button.

    ![nest.land with the generate api key button highlighted](https://dev-to-uploads.s3.amazonaws.com/i/w91oa8tpbyrqp80w8h1v.png)

1. You will be provided with your own unique API key. Note this and keep it secret and safe.

    ![nest.land page displaying new API key](https://dev-to-uploads.s3.amazonaws.com/i/4jvej2d3ija951o5tb10.png)

1. In an IDE / terminal of your choice, navigate to the root directory of the code you wish to publish as a module.

1. Install the nest.land `eggs` CLI by executing `deno install -A -f --unstable -n eggs https://x.nest.land/eggs@0.2.1/mod.ts` in your terminal. Further details are available on the [nest.land installation docs page](https://docs.nest.land/eggs/installation.html).

1. In your terminal execute `eggs link <key>`, making sure to replace `<key>` with the nest.land API key you generated earlier. This will save your API key on your local machine meaning you will be able to publish modules to nest.land without having to log in ever again. Further details are available in the [nest.land docs](https://docs.nest.land/eggs/linking-your-api-key.html).

1. Initialize your module (similar to `npm init`) to configure it for nest.land by executing `eggs init`. This will prompt you to enter a series of information regarding the module such as the name, description, version etc. The outcome will be a newly created `egg.json` in the root directory of your project which is very similar to a `package.json`. See the nest.land docs for [more information on initializing a module](https://docs.nest.land/eggs/initializing-a-module.html) and [details on the egg.json configuration](https://docs.nest.land/eggs/configuration.html).

1. Publish your module by executing `eggs publish`. See the [nest.land publish docs](https://docs.nest.land/eggs/publishing-a-module.html) for further information.

1. Confirm your module published successfully by navigating to the [nest.land gallery](https://nest.land/gallery) and searching for your module.

1. Clicking on your module should open a dedicated page including your module's readme and information on how to import your module from nest.land.

    ![SuperDeno module page in nest.land](https://dev-to-uploads.s3.amazonaws.com/i/hzx0fb227rfakho30xjk.png)

If you have any issues, the [nest.land](https://docs.nest.land/) docs are a good place to start. Alternatively you can reach out to the community and maintainers via the nest.land [GitHub discussions](https://github.com/nestdotland/nest.land/discussions) or [by raising an issue on the nest.land GitHub](https://github.com/nestdotland/nest.land/issues).

---

That's all folks! :tada:

Please drop any questions, queries and comments below. If your using a registry not mentioned in this article I would love to hear about it as well!

Till next time! 🚀