React UI kit authentication

When adding the <WeavyProvider> component, you need to specify a token factory function which should return a JWT with user claims for the signed in user. See Configuring authentication for more information about how to create the JWT.

The JWT token factory

The JWT token factory should be a function that Weavy can call whenever a JWT is needed. The function should return the JWT as a string or return a promise that resolves the JWT as shown in the example below.

import React from 'react';
import { WeavyClient, WeavyProvider } from '@weavy/uikit-react';

const getToken = () => {
   return new Promise(function (resolve, reject) {
       // typically an api call to your backend which returns a JWT
       var token = getTokenFromSomewhere();
       if (token) {
       } else {
           reject("Failed to retrieve token");

const weavyClient = new WeavyClient({ url: "https://url-to-weavy.backend", tokenFactory: getToken})

function App() {
   return (
       <div className="App">
           <WeavyProvider client={weavyClient}>
               <!-- Weavy components goes here -->

export default App;
Weavy Docs