Skip to content

Getting Started

Swarmd Workers are unit of work which are able to be instantiated and executed for each request. For now, only the javascript part of Swarmd Workers are implemented.

Swarmd Workers run on Node V8 Isolate with the Norn Runtime which is an overlay which will allow you to run workers written in Javascript.

If you don’t know about the Worker environment, you can view them as a NodeJS-like application where we changed the part that was linked to the OS like the file management.

In this page we’ll go through the whole process of creating a simple Javascript/Typescript Worker that you’ll be able to deploy to Swarmd with the cli.

It’ll be deployed across every swarmd region.

Installation

First of all, install the Swarmd CLI. If you want more information about the Swarmd CLI, refer to this documentation.

# This will install `swarmd` locally.
curl -fsSL https://raw.githubusercontent.com/swarmd-io/swarmd/main/install.sh | sh

To be sure the swarmd cli is available, just run swarmd --version and you should have the current version of the CLI.

Login

Before doing anything with Swarmd, ensure you have created an account here. Once your account is created, you can run swarmd login directly in the terminal to have the authentification flow running for your local installation.

Create a new Worker

Now that you are connected, you can create a demo project to test Swarmd by running:

swarmd create demo-project

It’ll create a new folder demo-project with a simple typescript worker set up.

Configure it

Go into the demo-project folder and initialize your nodes-modules by running npm install or pnpm install.

You can run your worker locally by running swarmd dev.

Deploy it

Once you have made your wanted modification, you can run swarmd deploy to deploy it globally in few seconds.