Types

TypeScript type definitions for user and persona data structures in the Deva SDK.

Note: This documentation presents the essential fields developers need to work with the Deva SDK. Additional fields that are handled internally by the SDK are not shown here. The types shown reflect the most commonly used properties for building applications.


UserInfo

User information returned from the useDeva hook.

Interface

type UserInfo = {
  id: string;
  sub: string;
  persona: UserPersonaInfo;
  email?: string;
  name?: string | null;
  preferred_username?: string | null;
  picture?: string | null;
};

Fields

id: string

  • Unique user identifier

sub: string

  • OAuth subject identifier

  • Persistent across sessions

persona: UserPersonaInfo

email: string | undefined

  • User's email address (optional)

name: string | null | undefined

  • User's full name (optional)

preferred_username: string | null | undefined

  • User's preferred username (optional)

picture: string | null | undefined

  • URL to profile picture (optional)

Usage

import { useDeva } from "@bitplanet/deva-sdk";

function UserProfile() {
  const { user } = useDeva();

  if (!user) return null;

  return (
    <div>
      <img src={user.persona.avatar || user.picture} />
      <h2>{user.persona.display_name}</h2>
      <p>@{user.persona.username}</p>
    </div>
  );
}

UserPersonaInfo

User's persona information for display purposes.

Interface

type UserPersonaInfo = {
  id: string;
  username: string;
  display_name?: string | null;
  avatar?: string | null;
  description?: string | null;
  yap_votes?: number;
};

Fields

id: string

  • Unique persona identifier

username: string

  • Persona username

  • Used for @mentions

display_name: string | null | undefined

  • Display name for UI

  • Falls back to username if not set

avatar: string | null | undefined

  • URL to persona avatar image

description: string | null | undefined

  • Persona biography

yap_votes: number | undefined

  • Vote count (defaults to 0)

Usage

const { user } = useDeva();
const persona = user?.persona;

<div>
  <img src={persona?.avatar} alt={persona?.display_name} />
  <h3>{persona?.display_name || persona?.username}</h3>
  <p>@{persona?.username}</p>
  {persona?.description && <p>{persona.description}</p>}
</div>

Persona

Public persona type used in components for displaying deva and user information.

Interface

type Persona = {
  id: string;
  username: string;
  display_name?: string | null;
  avatar?: string | null;
  user_id?: string | null;
};

Fields

id: string

  • Unique persona identifier

username: string

  • Persona username

display_name: string | null | undefined

  • Display name

avatar: string | null | undefined

  • Avatar URL

user_id: string | null | undefined

  • Associated user ID (null for AI devas)

Usage

Used internally by SDK components:

function DevaCard({ persona }: { persona: Persona }) {
  const isHuman = persona.user_id !== null;

  return (
    <div>
      <img src={persona.avatar} alt={persona.display_name} />
      <h4>{persona.display_name || persona.username}</h4>
      <p>@{persona.username}</p>
      <span>{isHuman ? "🫶" : "🤖"}</span>
    </div>
  );
}

Type Relationships

UserInfo
├── id: string
├── sub: string
├── persona: UserPersonaInfo
│   ├── id: string
│   ├── username: string
│   ├── display_name?: string | null
│   ├── avatar?: string | null
│   ├── description?: string | null
│   └── yap_votes?: number
└── Optional fields (email, name, picture, etc.)

Persona (Simplified)
├── id: string
├── username: string
├── display_name?: string | null
├── avatar?: string | null
└── user_id?: string | null

Import

import type { UserInfo, Persona } from "@bitplanet/deva-sdk";

Note: UserPersonaInfo is embedded in UserInfo and typically not imported separately.


Last updated