Gatsby Theme Cognito with Amplify
A wrapper theme to use Cognito (Amplify AWS) with your Gatsby website.
Installation
To use this theme in your Gatsby sites, follow these instructions:
-
Install the theme
npm install --save gatsby-theme-amplify-cognito -
Set up User Pool in AWS
-
Add the theme to your
gatsby-config.js
:moduleexports =plugins:resolve: `gatsby-theme-amplify-cognito`options:region: ''userPoolId: ''userPoolWebClientId: '' -
Populate the options with the details from your User Pool
-
Each page is passed a prop of authState and authData which contain the details of the user session
-
Use the components to create your page:
;const Homepage = {return <section>propsauthState !== "signedIn" ?<SignIn authState=authState /> :<><h1>Hello authDatausername</h1><SignOut /></></section>} -
Start your site
gatsby develop