Can anyone help me out, I’ve been stuck on this for days. I tried implementing the ReactJS chat using this https://codesandbox.io/s/github/AmityCo/Amity-Social-Cloud-Web-Sample-Apps/tree/main/messaging-app-with-CRA?file=/src/ascClient.js:0-636 on a NextJS app.
Each time I load the page I keep getting
Server Error
ASCError: ASCWebSDK: Only one instance of the SDK Web Client can be created
This error happened while generating the page. Any console logs will be displayed in the terminal window.
I cant figure to why this is happening.
cijin
June 22, 2023, 11:04am
2
Hey @coventi ,
If you are just starting out I’d recommend you use the Typescript SDK
instead.
npm i @amityco/ts-sdk
To achieve the same as above you could use this snippet:
import { Client } from '@amityco/ts-sdk'
(async () => {
const sessionHandler: Amity.SessionHandler = {
sessionWillRenewAccessToken(renewal: Amity.Renewal) {
renewal.renew();
/*
* If using an auth token
*
* try {
* renew.renewWithAuthToken(authToken)
* } catch() {
* sdk will try to renew again at a later time
*
* renew.unableToRetrieveAuthToken()
* }
*/
},
};
const client = Client.createClient(API_KEY, API_REGION)
let isConnected = await Client.login({ userId: USER_ID }, sessionHandler)
})()
This has sorted out the issue. Thanks Cijin
1 Like
cijin
June 26, 2023, 3:43am
4
Amazing! Please let me know if there are any other issues.
Happy to help.
Cijin