1.0.0-next.1 • Published 3 years ago
@ivyhjk/amplify-react-core-auth v1.0.0-next.1
React Amplify core authentication provider
React core authentication provider based on top of AWS Amplify
Install
with NPM:
npm install @ivyhjk/amplify-react-core-auth
with yarn:
yarn add @ivyhjk/amplify-react-core-auth
Usage
Put the context in your main application component:
import { CoreAuthContext } from '@ivyhjk/amplify-react-core-auth';
const App: React.Fc = () => (
<CoreAuthContext>
{/* ... */}
</CoreAuthContext>
);
Hooks
Get the current authenticated user, directly from amplify, without cache:
import { useCurrentAuthenticatedUser } from '@ivyhjk/amplify-react-core-auth';
const UserComponent: React.FC = () => {
const { error, loading, user } = useCurrentAuthenticatedUser();
return (
<p>
Welcome {user.name}
</p>
);
}
Get the current authenticated user, from context (fastest):
import { useUser } from '@ivyhjk/amplify-react-core-auth';
const UserComponent: React.FC = () => {
const user = useUser();
return (
<p>
Welcome {user.name}
</p>
);
}
1.0.0-next.10
3 years ago
1.0.0-next.5
3 years ago
1.0.0-next.6
3 years ago
1.0.0-next.7
3 years ago
1.0.0-next.8
3 years ago
1.0.0-next.3
3 years ago
1.0.0-next.1
3 years ago