Skip to main content

Getting Started

The Bettermode JavaScript client allows developers to effortlessly interact with Bettermode GraphQL API using Node.js or JavaScript on backend or frontend.

Create a JavasScript client

To get started, you can simply install @tribeplatform/gql-client and use it in your JavaScript project.

npm install @tribeplatform/gql-client

To perform actions or queries using Bettermode JavaScript client, you need to first generate an access token. To do so, you need to first create an app and use the app's client ID and client secret.


Don't have an app yet? Follow the instructions here.

import { GlobalClient, TribeClient } from '@tribeplatform/gql-client'

const globalClient = new GlobalClient({
clientId: '{CLIENT_ID}',
clientSecret: '{CLIENT_SECRET}',
graphqlUrl: '', // This URL is same for both US and EU communities. You don't need to change it.
onError: (errors, client, error) => {
console.error(error, errors, client)

const client = bettermodeClient.getTribeClient({ networkId: '{networkId}' })

You should replace {clientId}, {clientSecret}, {networkId}, and with app's client ID, app's client secret, network/community ID.


You can generate an access token on behalf of a user by passing memberId like this:

const client = bettermodeClient.getTribeClient(
networkId: '{networkId}',
memberId: '{memberId}'

Not providing memberId will generate access token for a bot account.