rook-provider
v0.5.1
Published
RookMotion Auth contains a Provider to notify the submodules if the apps is authorized by the given token
Downloads
8
Readme
RookMotion Auth
RookMotion Auth contains a Provider to notify the submodules if the apps is authorized by the given token
Instalation
npm
npm i rook-provider
yarn
yarn add rook-provider
Usage
The package include a component call RookMotionProvider, it should preferably be used at the root of your component tree. RookMotionProvider needs the token that was given to you.
import { RookMotionProvider } from 'rook-provider'
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<RookMotionProvider token='YOUR-TOKEN'>
<App />
</RookMotionProvider>
</React.StrictMode>
)
Then to verify if the apps was allowed you need to use the hook useRookAuth, this give you two flags:
- ready: indicate if the package is fully loaded
- authenticated: indicate if the app was allowed.
import { useRookAuth } from 'rook-provider'
const myComponent = () => {
...
const { ready, authenticated } = useRookAuth()
...
}