Could not Initialize the Realm App Client

Hi Everyone, I am learning to use Mongodb Realm. I am trying to connect Realm App Client in my web sdk. But getting Realm.App.getApp is not a function error. Please see my code below and help me where I am doing wrong here.
<script src=""></script>

In JS,

const id = ‘< My App ID>’; // replace this with your App ID

const config = {
const app = new Realm.App(config);

async function loginAnonymous() {

// Create an anonymous credential
const credentials = Realm.Credentials.anonymous();
try {
  // Authenticate the user
  const user = await app.logIn(credentials);
  // `App.currentUser` updates to match the logged in user
  return user
} catch(err) {
  console.error("Failed to log in", err);

loginAnonymous().then(user => {
console.log(“Successfully logged in!”, user)
const app = Realm.App.getApp("< My App ID>"); // replace this with your App ID
// Getting error here as Realm.App.getApp is not a function

It looks like you’re using an older version, can you try using realm-web@1.2.0 in the HTML instead of 0.8.0?

1 Like