Building a POC in JS

Just started working on building a Proof of Concept for my application. We want to use Amity to implement conversations between users on our site.

I started by just trying to run the client code provided and installing the sdk via npm and create a user like so

import AmityClient, { ApiRegion } from “@amityco/js-sdk”;

const client = new AmityClient({
  apiKey: "b0e8ee0f3edfa53019308914545b148a855f8fe6e9616b7a",
  apiRegion: ApiRegion.US,

client.registerSession(1, “Drew”)

But I’m receiving SyntaxError: Named export ‘ApiRegion’ not found. The requested module ‘@amityco/js-sdk’ is a CommonJS module, which may not support all module.exports as named exports.

I tried to switch the imports a bit like this instead

import AmityClient from “@amityco/js-sdk”;
const { ApiRegion } = AmityClient

But it is still giving me an error
TypeError: AmityClient is not a constructor

Any help so I can get started would be greatly appreciated. I was under the impression that I could implement this with just vanilla js.

Hey @dmadorno,

If you are just starting out I would recommend you try the Typescript SDK instead.

You can find it here
Let me know if you have any challenges with implementing the SDK, happy to help.

As for the issue with the JS-SDK, could I know which version you are using. I’ve tried it running locally and seems to be working fine. Could you check if this works?

import * as Amity from '@amityco/js-sdk'

const { ApiRegion } = Amity;