Skip to content

kazukinagata/next-amplify-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 and checkAuth to use with typescript
  • Simple withSSRAuth hoc for SSR

Getting Started

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.

Utils

useAuthCtx

  const {data, loading} = useAuthCtx()
  // data: CognitoUser | null
  // loading: boolean

withSSRAuth

  // pages/index.tsx

  export const getServerSideProps = withSSRAuth(async (ctx) => {
    return {
      props: {}
    }
  })

Lisence

MIT