Custom Data

LAST EDIT May 07 2021

Changing the default extra data types with your custom types is easy and takes a couple of easy steps.

For example, let's say you want to replace the default NoExtraData of ChatChannel with your custom NameAndColorExtraData:

1. Define your custom Channel extra data type


Your custom data type must conform to the ChannelExtraData protocol. The protocol has two requirements: the type must be codable, and it must expose a static defaultValue variable.

2. Use the type in your custom implementation of ExtraDataTypes


3. Define the following typealiases in your module


You should define the convenience typealiases in the module where you use StreamChat. You can copy&paste the snippet below, and replace MyCustomExtraData with the type defined in step 2.



Extra data is embedded directly to the root object, not nested under any extraData object.

So if you have such a Channel object: