Live Video link ==> https://www.youtube.com/watch?v=Z6XR_HXK9Wg A comprehensive travel planning application built with Next.js, MongoDB, and NextAuth.js.
- Authentication System: Complete auth flow with NextAuth.js
- Email/password registration and login
- Google OAuth integration
- Forgot password with email reset
- Secure session management
- Frontend: Next.js 14 (App Router), React 18, Tailwind CSS
- Backend: Next.js API Routes, MongoDB with Mongoose
- Authentication: NextAuth.js with JWT sessions
- Styling: Tailwind CSS with custom design system
- Deployment: Vercel-ready
- Node.js 18+ installed
- MongoDB database (local or cloud)
- Google OAuth credentials (optional)
- Email server credentials (optional, for password reset)
- Clone the repository and install dependencies:
npm install- Set up environment variables:
cp .env.local.example .env.localEdit .env.local with your configuration:
# Required
MONGODB_URI=mongodb://localhost:27017/globetrotter
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here
# Optional - for Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# Optional - for email functionality
EMAIL_SERVER_HOST=smtp.gmail.com
EMAIL_SERVER_PORT=587
EMAIL_SERVER_USER=your-email@gmail.com
EMAIL_SERVER_PASSWORD=your-app-password- Start the development server:
npm run dev- Open http://localhost:3000 in your browser.
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Add the client ID and secret to your
.env.local
For Gmail:
- Enable 2-factor authentication
- Generate an app password
- Use the app password as EMAIL_SERVER_PASSWORD
Create test accounts using the registration form or use Google OAuth.
- Registration: Create account with email/password
- Login: Sign in with credentials or Google
- Forgot Password: Request password reset email
- Reset Password: Use reset link to set new password
- Session Management: Verify sessions persist and logout works
/app
/api/auth/ # Authentication API routes
/auth/ # Auth pages (login, register, etc.)
/dashboard/ # Protected dashboard area
layout.jsx # Root layout with providers
page.jsx # Home page
/components
/ui/ # Reusable UI components
/layout/ # Layout components
/providers/ # Context providers
/lib
mongodb.js # Database connection
auth.js # NextAuth configuration
/models
User.js # User model with Mongoose
- All code is in JSX format (no TypeScript)
- Uses Next.js App Router with both server and client components
- MongoDB integration with Mongoose ODM
- Secure password hashing with bcryptjs
- Rate limiting and security best practices implemented
- Responsive design with Tailwind CSS
This completes the Authentication Feature (Feature 1).
Ready for the next feature implementation:
- Dashboard/Home Screen (Feature 2)
- Create Trip Screen (Feature 3)
- My Trips (Trip List) Screen (Feature 4)
- And so on...
The application is ready for Vercel deployment:
npm run buildMake sure to configure environment variables in your Vercel dashboard.