YsAuth Amplify (AWS Cognito User Pool) Authentication
This library is helper to aws amplify (with Cognito user pool) authentication with react
How To Use
Provider
On top of your app need to add YsAuth Provider as describe below
First of all you need to import provider
import { YsAuthProvider } from 'ysauth';
Then impliment like this (for example)
<YsAuthProvider>
<React.StrictMode>
<App />
</React.StrictMode>
</YsAuthProvider>
Configure Amplify
import { YsAuthAmpliftConfig } from 'ysauth';
And the configuration itself
YsAuthAmpliftConfig({
region: '###',
userPoolId: '###',
userPoolWebClientId: '###',
});
That’s It! ?
Now you can call usAuth wherever you want to use.
import { useAuth } from 'ysauth';
Uses
const auth = useAuth();
auth.loading;
auth.getCurrentUser();
auth.login('username', 'password');
auth.logout();
auth.resetPassword('username', 'password', 'resetCode');