0

I have started working with microfronted.Riqht now I'm struggling sharing data between two apps.

For example I have appA (container) and appB. AppA handles authentication, stores jwt token in localStorage. AppB sends requests to backend. For each request I need to add jwt token. How I can pass jwt token and some other data(userID) from appA to AppB ?

This is my AppA

import React from 'react';

const AuthForms = React.lazy(() => import('login/AuthForm'));


const App = () => {
  
  return (
    <div className={classes.root}>
      <div className={classes.contentWrapper}>
      <React.Suspense fallback={<p>Loading content from app 2...</p>} >
        <AuthForms  />
      </React.Suspense>
      </div>
    </div>
  );
}

export default App;

AppB

import React, { useState } from 'react';

const AuthForms = () => {
    return (
        <div  className={classes.formWrapper}>
        I need jwt token in appB
        </div>
    );
};
export default AuthForms;
Yerlan Yeszhanov
  • 2,149
  • 12
  • 37
  • 67

0 Answers0