Javascript

Learn how to setup our framework agnostic javascript client

1

Install the SDK

Using npm:

npm install @clustersxyz/sdk viem

Or yarn:

yarn add @clustersxyz/sdk viem
2

Get an optional API Key

You can get an API Key by visiting https://clusters.xyz/developer/api-keys

3

Create your Clusters client

Import

import { Clusters } from "@clustersxyz/sdk"

// 3 different examples
const clusters = new Clusters();

// with testnet enabled
const clusters = new Clusters({ isTestnet: true }) 

// with api key
const clusters = new Clusters({ apiKey: "abc123" });

Helper functions & variables

validNameRegex

The regex for a valid cluster name

getImageUrl(name)

Get's the profile pfp url of a specific cluster name

getProfileUrl(name)

Get's the profile url of a cluster name

normalizeName(name)

Will clean up the name for onchain submission

isNameValid(name)

Checks if the name is a valid name and will be accepted on chain

Last updated