https://github.com/nrobledosagredo/nextjs-cognito-auth
A Next.js application integrating with AWS Cognito for authentication.
https://github.com/nrobledosagredo/nextjs-cognito-auth
authentication cognito nextjs
Last synced: 2 months ago
JSON representation
A Next.js application integrating with AWS Cognito for authentication.
- Host: GitHub
- URL: https://github.com/nrobledosagredo/nextjs-cognito-auth
- Owner: nrobledosagredo
- Created: 2025-03-06T20:14:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-06T22:13:25.000Z (over 1 year ago)
- Last Synced: 2025-03-06T23:22:20.850Z (over 1 year ago)
- Topics: authentication, cognito, nextjs
- Language: TypeScript
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Next.js with AWS Cognito Authentication







## Overview
Implementation of AWS Cognito authentication in a Next.js application.
Uses AWS Amplify to simplify integration with Cognito services. Users can sign up, sign in, and log out while utilizing Cognito as the authentication provider.
## Features
- **User authentication**: Sign up, sign in, and log out functionalities powered by AWS Cognito.
- **Secure sessions**: Automatically manage user sessions using **AWS Amplify**.
- **Cognito user pool**: Integration with a Cognito user pool for authentication.
- **Protected routes**: Ensures that only authenticated users can access specific pages.
## Setup
1. **Clone the repository:**
```bash
git clone https://github.com/your-username/nextjs-cognito-auth.git
cd nextjs-cognito-auth
```
2. **Install dependencies:**
```bash
npm install
```
3. **Configure AWS Cognito:**
Set up a Cognito user pool and app client in the [Cognito Console](https://console.aws.amazon.com/cognito). Note down the **User Pool ID** and **App Client ID**.
4. **Add environment variables:**
In the root of your project, create a `.env.local` file and add the following:
```bash
NEXT_PUBLIC_COGNITO_USER_POOL_ID=your_user_pool_id
NEXT_PUBLIC_COGNITO_CLIENT_ID=your_app_client_id
NEXT_PUBLIC_COGNITO_REGION=your_aws_region
```
5. **Run the application:**
```bash
npm run dev
```
Visit `http://localhost:3000` in your browser.