A modern, secure user authentication system built with Next.js and Clerk, featuring email verification, password reset, and profile management.
- Secure Authentication: Complete authentication flow with sign-up, sign-in, and sign-out
- Email Verification: Email verification using both code and link methods
- Password Management: Password reset and recovery functionality
- Profile Management: User profile editing and management
- Multiple Email Addresses: Support for adding and managing multiple email addresses
- Primary Email Selection: Ability to change primary email address
- Protected Routes: Server-side and client-side route protection
- Responsive Design: Mobile-friendly interface with Tailwind CSS
- Next.js: React framework for server-rendered applications
- Clerk: Authentication and user management
- Tailwind CSS: Utility-first CSS framework
- React Hook Form: Form validation and handling
- Yup: Schema validation
- Node.js 16.x or later
- npm or yarn
- Clerk account (for authentication)
-
Clone the repository:
git clone https://github.com/Armand9999/user-auth.git cd user-auth -
Install dependencies:
npm install # or yarn install -
Create a
.env.localfile in the root directory with your Clerk API keys:NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_publishable_key CLERK_SECRET_KEY=your_secret_key NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/profile NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/profile -
Start the development server:
npm run dev # or yarn dev -
Open http://localhost:3000 in your browser to see the application.
user-auth-nextjs/
├── app/ # Next.js app directory
│ ├── component/ # Reusable components
│ ├── profile/ # Profile pages
│ ├── sign-in/ # Sign-in pages
│ ├── sign-up/ # Sign-up pages
│ ├── page.js # Home page
│ └── layout.js # Root layout
├── middleware.ts # Authentication middleware
├── public/ # Static assets
├── .env.local # Environment variables (create this)
├── next.config.js # Next.js configuration
├── package.json # Project dependencies
└── tailwind.config.js # Tailwind CSS configuration
- Sign Up: Users create an account with email and password
- Email Verification: Users verify their email address
- Sign In: Users sign in with verified credentials
- Profile Management: Users can update their profile information
- Email Management: Users can add additional email addresses and change their primary email
- Password Reset: Users can reset their password if forgotten
This application can be deployed to Vercel with minimal configuration:
- Push your code to a GitHub repository
- Import the project to Vercel
- Add your environment variables in the Vercel dashboard
- Deploy!
This project is licensed under the MIT License - see the LICENSE file for details.