JSFiddle - React, Tailwind, and code Playground

by thelifeisyours

HTML

<script src="https://unpkg.com/[email protected]/dist/bundle.iife.js"></script>

JavaScript

import * as Realm from "realm-web";

const app = new Realm.App({ id: "<Your App ID>" });

// 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
  assert(user.id === app.currentUser.id)
  return user
} catch(err) {
  console.error("Failed to log in", err);
}

const summed = await app.functions.sum(2,3);
assert(summed === 5);