@20i/cognito-react
v0.1.2-alpha
Published
A nice api to initialize and interact with Cognito from React.
Downloads
11
Maintainers
Keywords
Readme
@20i/cognito-react
A nice api to initialize and interact with Cognito from React.
Peer dependencies
"@aws-amplify/auth": "^4.0.3",
"react": "^17.0.2",
"react-query": "3.19.0",
"axios": "^0.21.1",
"react-dom": "^17.0.2"
Installation
npm login
npm i @20i/20i-cognito-react
Usage
import { Cognito } from "@20i/cognito-react"
import config from "./config"
const { cognito } = config
Cognito.configure(cognito)
const hooks = Cognito.Hooks((authUser: CognitoUser) => {
const user = getUser(authUser)
// Do stuff with the Cognito AuthUser to get the rest of the user data
// (Like retrieve it from the DB, etc)
return user
})
// The hooks returned from Cognito.Hooks will use the supplied lambda
// to retrieve the user in their respective logicks
export const useUser = hooks.useUser
export const useAuthUser = hooks.useAuthUser