This guide explains how to use our commenting widget via an SDK. For more general information on our commenting widget, read this guide.
yarn add @peerboard/core@^0.0.20
https://gist.github.com/sentiens/267f45aff41786b4c701dd6e250689da
Useful links:
Hot to generate JWT authentication token
Additional features
Show / Hide link to a community
You could use the option to show or hide link to a community.
const options = {
// some options, example is above
enableCommunityLink: false, // default "true"
}
Also, you can set the default option on the page Widgets -> Commenting Widget

Custom title and content for post
You could use a custom title or content at creating a post. You need add the special option postOptions for SDK integration commenting widget.
const options = {
// some options, example is above
postOptions: {
title: 'Title for post', // string
// Only plain text or markdown
content: 'Content text or markdown until 128kb', // only string
},
}
Also, you can set the default option on the page Widgets -> Commenting Widget
Custom author for post
You could use a custom author at creating post. You need add the special option widgetToken for SDK integration commenting widget.
Save your PeerBoard API Auth Token at a secure location on your backend server. You can find the token at your community Settings -> Hosting.
const apiAuthToken = "<API AUTH TOKEN>";
Install the JWT library of your choice.
Payload example is below, you can only use one field instead of all
const payload = {
"creds": {
"post_author": {
// We highly recommend to provide unique user id from you system
// to be keep things in sync in the future
// Email is a bad identifier(it may change). Should be a string.
"external_user_id": string
// internal user id
"user_id": int
// Required to send notifications and digests.
"email": string
}
}
}
We recommend to restrict the lifetime of the token, but give it enough time so if a user stays on your page, the link will still work after a while.
const jwtOpts = {
expiresIn: 3600 // seconds
};
Sign JWT token
const token = jsonwebtoken.sign(payload, apiAuthToken, jwtOpts);
Add JWT token in SDK options for commenting widget
const options = {
// some options, example is above
widgetToken: 'JWT Token with hidden options for example post author',
}
Questions?
Post in the comments!