decentrl.
SDK

Getting Started

Install the Decentrl SDK and build your first encrypted application.

Prerequisites

  • Node.js 20 or later
  • TypeScript with "moduleResolution": "bundler" or "node16"
  • A package manager (npm, pnpm, or yarn)

Installation

npm install @decentrl/sdk zod

For React applications, also install the React bindings:

npm install @decentrl/sdk-react

TypeScript Configuration

Decentrl uses native ES modules. Your tsconfig.json must use ESM-compatible settings:

tsconfig.json
{
  "compilerOptions": {
    "module": "esnext",
    "moduleResolution": "bundler",
    "target": "ES2022"
  }
}

Quick Start

Define your app, create a client, publish an event:

app.ts
import { defineDecentrlApp } from '@decentrl/sdk'
import { z } from 'zod'

const app = defineDecentrlApp({
  events: {
    message: {
      schema: z.object({
        text: z.string(),
        threadId: z.string().uuid(),
      }),
      tags: ['thread.${threadId}'],
    },
  },
  state: {
    messages: {
      initial: [],
      reduce: {
        message: (state, data) => [...state, data],
      },
    },
  },
})

const client = app.createClient({
  mediatorDid: 'did:web:mediator.decentrl.io',
})

// Create identity on first launch
await client.identity.create({
  alias: 'alice',
  mediatorDid: 'did:web:mediator.decentrl.io',
})

// Publish an encrypted event
await client.publish('message', {
  text: 'Hello, private world.',
  threadId: crypto.randomUUID(),
})

createClient() sets up the transport layer. identity.create() generates keys, creates a DID, and registers with the mediator. The client is then ready to publish events, manage contracts, and query encrypted state.

Public Beta. Decentrl is in active development. The protocol specification is at v0.1. APIs may change between minor versions. Pin your dependency to avoid surprises.