3.0.26 • Published 1 year ago

react-sso-provider v3.0.26

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

REACT SSO PROVIDER

Share local storage of your React application across domains

Installation

  npm install react-sso-provider

Host App

To make your app a host. Import HostContextProvider

import { HostContextProvider } from "react-sso-provider";

Wrap your app with the provider

<HostContextProvider
  guestDomains={[
    {
      origin: "https://<guest domain>",
      allowedMethods: ["get", "set", "remove"],
    },
  ]}
>
  {children}
</HostContextProvider>

It takes guestDomains as props . This prop (guestDomains) is an array of domains you want to provide access to the localstorage of your Host aaplication.

Guest App

To make your app a guest. import GuestContextProvider

import { GuestContextProvider } from "react-sso-provider";

Wrap your app in GuestContextProvider

<GuestContextProvider hostDomain="http://<host domain>">
  {children}
</GuestContextProvider>

Now , in the guest app you can use the guest context.

const {
  getHostStorageVariable,
  setHostStorageVariable,
  removeHostStorageVariable,
} = useContext(GuestContext);

These function destructured from the guest context return Promise. So we need to await.

getHostStorageVariable=> this function fetches localstorage variable of host

setHostStorageVariable=> this function sets localstorage variable of host

setHostStorageVariable=> this function deletes localstorage variable of host

3.0.26

1 year ago

3.0.23

1 year ago

3.0.24

1 year ago

3.0.21

1 year ago

3.0.2

1 year ago

3.0.22

1 year ago

3.0.1

1 year ago

3.0.25

1 year ago

3.0.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago