Skip to main content

Function: defineContact()

defineContact(id, options): Contact

Defined in: contacts.ts:59

Defines a chat participant.

Parameters

id

string

Unique, persistent identifier

options

ContactOptions = {}

Display name, avatar, and any author metadata

Returns

Contact

The contact, usable anywhere a sender is expected

Throws

Error if the id is already taken or is a reserved sender id

Example

import { defineContact, m } from '@react-text-game/messenger';

export const anna = defineContact('anna', {
name: m.t('contacts.anna'),
avatar: '/avatars/anna.webp',
});