gatsby-theme-amplify-cognito
v3.0.0
Published
A wrapper theme to use Cognito (Amplify AWS) with your Gatsby website.
Downloads
3
Maintainers
Readme
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
:module.exports = { 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:
import { SignIn, SignOut } from 'gatsby-theme-amplify-cognito'; const Homepage = ({authState, authData}) => { return <section> {(props.authState !== "signedIn") ? <SignIn authState={authState} /> : <> <h1>Hello {authData.username}</h1> <SignOut /> </> } </section> }
Start your site
gatsby develop