This is a Next.js x Amplify boilerplate that includes following;
- material-ui with ssr support
- styled-components with ssr support
- react-toastify
- nprogress
- Configured Amplify auth context, use
useAuthCtx
to retrieve current user - Convenience utilities such as
callGraphQL
andcheckAuth
to use with typescript - Simple withSSRAuth hoc for SSR
First, install amplify CLI if have not installed yet:
npm install -g @aws-amplify/cli
Then initialize amplify project
amplify init
Next, install packages and run the development server:
npm install
# or
yarn
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser to see the result.
const {data, loading} = useAuthCtx()
// data: CognitoUser | null
// loading: boolean
// pages/index.tsx
export const getServerSideProps = withSSRAuth(async (ctx) => {
return {
props: {}
}
})
MIT