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.
- Client authentication
- Accessing the user session on the client
- Protected client routes
- Client-side redirects
- Accessing the user session in a server-side route (getServerSideProps)
- Protected server routes (getServerSideProps)
- Server-side redirects (getServerSideProps)
- Accessing the user session in an API route
- Deploying the app using the Next.js Serverless Component
To deploy the authentication service and run the app, follow these steps:
- Clone the repo
git clone https://github.com/dabit3/next.js-authentication-aws.git
- Change into the directory and install the dependencies
cd next.js-authentication-aws
npm install
- Initialize the Amplify project
amplify init
- Deploy the authentication service
amplify push --y
- Run the app locally
npm run dev
Deploying with Serverless Framework
npx serverless