In Comments, each thread can be given custom metadata. This is helpful for integrating Comments into various applications, for example it can be used to store:
You can store any string
, boolean
, or number
in thread metadata, for
example:
Setting a property to null
will remove it.
You can store up to 50 metadata properties per thread, and each property can be 4000 characters long.
Metadata can be set using the default components, React hooks, or by editing thread using the REST APIs. But before making any changes, it’s recommended to set your metadata type in your config file.
Learn more about typing your data.
The <Composer />
component
is used to create threads and comments, and by default it’ll create a new
thread, with optional metadata, when its form is submitted.
When using it to create a thread, you can pass custom metadata, which will be attached to the thread.
Two mutation hooks
allow you to edit thread metadata:
useEditThreadMetadata
and
useCreateThread
.
Here’s one way to create a button that sets the pinned
metadata property to
true
.
These hooks are exported from your config file and provide full typing.
It’s possible to modify metadata from our REST APIs using the
@liveblocks/node
package. Here’s an
example using
liveblocks.editThreadMetadata
.
The same result can also be achieved directly through our edit thread metadata REST API.
We use cookies to collect data to improve your experience on our site. Read our Privacy Policy to learn more.