/next.js-authentication-aws

This project deploys a Next.js project to AWS with comprehensive authentication enabled

Primary LanguageJavaScript

Next.js authentication with AWS

This code goes along with my tutorial The complete Guide to Authentication with Next.js and AWS

This project contains an end to end solution for Next.js authentication on AWS with AWS Amplify.

  1. Client authentication
  2. Accessing the user session on the client
  3. Protected client routes
  4. Client-side redirects
  5. Accessing the user session in a server-side route (getServerSideProps)
  6. Protected server routes (getServerSideProps)
  7. Server-side redirects (getServerSideProps)
  8. Accessing the user session in an API route
  9. Deploying the app using the Next.js Serverless Component

To deploy the authentication service and run the app, follow these steps:

  1. Clone the repo
git clone https://github.com/dabit3/next.js-authentication-aws.git
  1. Change into the directory and install the dependencies
cd next.js-authentication-aws

npm install
  1. Initialize the Amplify project
amplify init
  1. Deploy the authentication service
amplify push --y
  1. Run the app locally
npm run dev

Deploying with Serverless Framework

npx serverless