Verida Documentation
  • Welcome
  • Network Overview
  • Start Building
  • Verida Wallet
  • Whitepapers
  • Glossary
  • Protocol
    • Core concepts
      • Design Principles
      • Decentralized Identity
      • Confidential Databases
      • Confidential Compute
      • Accounts and Identity
      • Data Storage
      • Application Contexts
      • Messaging
      • Schemas
      • Data Sharing
    • Client SDK
      • Getting Started
      • How It Works
      • Authentication
      • Data
      • Queries
      • Permissions
      • Messaging
      • Account Profiles
      • Events
      • Command Line Tools
      • Configuration
      • React Native
      • Advanced
    • Verida Connect SDK
      • Getting Started
      • WebUser
      • WalletConnect Support
      • Authentication Server
    • Blockchain Bridge
    • Run a Node
      • Database Node
        • Setup
        • Operations
        • FAQ
      • Compute Node
    • Verida Networks
  • Extensions
    • Credentials
      • Verifiable Credentials Developer SDK
      • cheqd Credential Service
      • Privado ID (fmr Polygon ID)
      • zkPass credentials
      • Reclaim Protocol credential
    • Verida URIs
    • Vue Components
Powered by GitBook
On this page
  • Installation​
  • Authentication​
  • How to Use​

Was this helpful?

  1. Protocol
  2. Client SDK

Getting Started

PreviousClient SDKNextHow It Works

Last updated 8 months ago

Was this helpful?

In this article, we walk you through the process setting up the Verida Client SDK and guide you through the process of initializing and using the library in your applications.

You can interactively use the Verida client library in your browser using the .

Installation

Start by installing the Verida client protocol library and Verida Wallet authentication method:

npm install @verida/client-ts @verida/account-web-vault

You may receive compilation warnings when using typescript regarding pouchdb. If that happens, add the pouchdb-core type definitions:

npm install --dev @types/pouchdb-core

Authentication

Initialize a connection to the Verida network using a private key stored on the user’s mobile device using the Verida Wallet:

import { Network as NetworkClient } from '@verida/client-ts';
import { Network } from '@verida/types';
import { VaultAccount } from '@verida/account-web-vault';

const VERIDA_NETWORK = Network.BANKSIA; // BANKSIA (testnet) or MYRTLE (mainnet)
const CONTEXT_NAME = 'My Application Context Name';

// The LOGO_URL should be a 170x170 PNG file
const LOGO_URL = "https://assets.verida.io/verida_login_request_logo_170x170.png";

const account = new VaultAccount({
    logoUrl: LOGO_URL
});

const context = await NetworkClient.connect({
    client: {
        network: VERIDA_NETWORK,
    },
    account: account,
    context: {
        name: CONTEXT_NAME,
    },
});

Note: Change Network.BANKSIA to Network.MYRTLE to use a mainnet network.

  • CONTEXT_NAME: A string representing your decentralized application. By convention prefix it with your company name. ie: Verida: My Application.

You can now verify the user has connected successfully to your application:

const did = await account.did();
console.log('User is connected with Verida Account DID: ' + did);

You can open a database, save a record and then fetch it:

const db = await context.openDatabase('test_db');
const item = await db.save({
    hello: 'world',
});
const items = await db.getMany();
console.log(items);

about different authentication methods.

How to Use

Learn more about building applications with decentralized and .

Verida Web Sandbox
​
​
​
databases, datastores
messaging
Learn more