https://github.com/lskeey/next-auth-v5
Authentication solution for Next.js apps, providing seamless and secure user login with NextAuth.js v5.
https://github.com/lskeey/next-auth-v5
authjs nextjs postgresql shadcn-ui tailwindcss
Last synced: 3 months ago
JSON representation
Authentication solution for Next.js apps, providing seamless and secure user login with NextAuth.js v5.
- Host: GitHub
- URL: https://github.com/lskeey/next-auth-v5
- Owner: lskeey
- Created: 2024-10-20T14:20:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-02T13:56:44.000Z (over 1 year ago)
- Last Synced: 2025-02-09T08:42:06.348Z (over 1 year ago)
- Topics: authjs, nextjs, postgresql, shadcn-ui, tailwindcss
- Language: TypeScript
- Homepage:
- Size: 712 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
🛡️ NEXT-AUTH-V5
Seamless Security, Limitless Possibilities
Built with the tools and technologies:
This project is a robust, full-featured authentication system built with Next.js App Router and Next-Auth v5. It provides a modern, secure, and highly customizable foundation for your web applications, handling everything from user registration to multi-factor authentication.
## ✨ Key Features
- **Credentials & Social Authentication**: Secure login via email and password, or seamlessly with Google and GitHub OAuth providers.
- **Email Verification**: A streamlined process to confirm new user accounts through email, enhancing security and preventing spam.
- **Password Reset**: Built-in functionality for users to securely reset their forgotten passwords.
- **Two-Factor Authentication (2FA)**: An extra layer of security with two-factor authentication, using an OTP sent to the user's email.
- **Role-Based Access Control**: Protect your routes and server actions based on user roles (Admin/User), ensuring proper authorization throughout your application.
- **Client & Server Component Protection**: Middleware protects routes from unauthorized access, both on the client and server sides.
- **Modern UI**: Beautiful and responsive design, crafted using **Shadcn/UI** and **Tailwind CSS**.
## 🚀 Getting Started
Follow these simple steps to get the project up and running on your local machine.
### Prerequisites
- Node.js (>= 18.17.0)
- PostgreSQL or another supported database for Prisma
- A **Resend** API key for sending emails.
- **Google** and **GitHub** OAuth client IDs and secrets for social logins.
### Installation
1. **Clone the repository**:
```bash
git clone https://github.com/lskeey/next-auth-v5.git
cd next-auth-v5
```
2. **Install dependencies**:
```bash
npm install
# or
yarn install
# or
pnpm install
```
3. **Set up environment variables**:
Create a `.env` file at the root of the project and copy the contents from `.env.example`. Replace the placeholder values with your own keys.
```env
# Prisma connection string
DATABASE_URL=
# Next-Auth secret
AUTH_SECRET=
# OAuth providers
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# Resend API key for emails
RESEND_API_KEY=
```
4. **Database Setup**:
Initialize and migrate your database using Prisma.
```bash
npx prisma migrate dev
```
5. **Run the development server**:
```bash
npm run dev
```
Open [http://localhost:3000](http://localhost:3000) in your browser.
## 📂 Project Structure
- `actions/`: Server actions for handling authentication logic (e.g., login, register, reset).
- `app/`: Next.js App Router for all pages and API routes.
- `components/`: Reusable UI components including form wrappers, buttons, and user information displays.
- `data/`: Data access layer for interacting with the database using Prisma.
- `hooks/`: Custom React hooks for client-side state management, like fetching the current user or role.
- `lib/`: Core utility functions, including database connection, authentication helpers, and mailer setup.
- `prisma/`: Prisma schema and database configuration.
- `schemas/`: Zod schemas for form validation.
## 🤝 Contribution
Contributions are welcome! If you'd like to improve this project, please feel free to open an issue or submit a pull request.
## 📄 License
This project is licensed under the MIT License.