{"id":24902890,"url":"https://github.com/dharmveer97/next-auth-mongoose","last_synced_at":"2026-04-02T04:47:45.613Z","repository":{"id":275218345,"uuid":"925443734","full_name":"dharmveer97/next-auth-mongoose","owner":"dharmveer97","description":"A  production-ready authentication template with NextAuth v5, MongoDB/Mongoose, and TypeScript. Supports credentials + OAuth providers.","archived":false,"fork":false,"pushed_at":"2025-01-31T22:35:35.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T23:24:47.602Z","etag":null,"topics":["custom-form","formik","middleware","mongodb","mongoose","next-auth-v5","nextjs15","react19","typescript","vercel","vercel-deployment","yup"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dharmveer97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-31T22:24:01.000Z","updated_at":"2025-01-31T22:35:38.000Z","dependencies_parsed_at":"2025-02-01T05:30:26.398Z","dependency_job_id":null,"html_url":"https://github.com/dharmveer97/next-auth-mongoose","commit_stats":null,"previous_names":["dharmveer97/next-auth-mongoose"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharmveer97%2Fnext-auth-mongoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharmveer97%2Fnext-auth-mongoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharmveer97%2Fnext-auth-mongoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharmveer97%2Fnext-auth-mongoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dharmveer97","download_url":"https://codeload.github.com/dharmveer97/next-auth-mongoose/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245910437,"owners_count":20692450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-form","formik","middleware","mongodb","mongoose","next-auth-v5","nextjs15","react19","typescript","vercel","vercel-deployment","yup"],"created_at":"2025-02-01T22:17:42.468Z","updated_at":"2025-12-30T20:32:26.108Z","avatar_url":"https://github.com/dharmveer97.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n```markdown\n# NextAuth v5 + Next.js 15 + React 19 + Mongoose Starter 🔥\n\n\nA production-ready authentication template using NextAuth v5, MongoDB/Mongoose, and TypeScript. It supports both credentials and OAuth providers.\n\n## 🚀 Quick Start\n\n### 1. Clone the repository:\n\n```bash\ngit clone git@github.com:dharmveer97/next-auth-mongoose.git\ncd next-auth-mongoose\n```\n\n### 2. Install dependencies\n\n```bash\nnpm install\n# or\nbun install\n```\n\n### 3. Create a `.env.local` file\n\n```env\nMONGODB_URI=\"your_mongodb_connection_string\"\nNEXTAUTH_SECRET=\"generated_secret_here\"\nNEXTAUTH_URL=\"http://localhost:3000\"\nGOOGLE_CLIENT_ID=\"your_google_oauth_id\"\nGOOGLE_CLIENT_SECRET=\"your_google_oauth_secret\"\n```\n\n### 4. Generate `NEXTAUTH_SECRET`\n\n```bash\nopenssl rand -base64 32\n# or\nnpx auth secret\n```\n\n### 5. Start the development server\n\n```bash\nnpm run dev\n# or\nbun run dev\n```\n\n## 🔧 Key Technologies\n\n- **Authentication**: NextAuth v5\n- **Database**: MongoDB + Mongoose ODM\n- **Frontend**: React 19 + TypeScript\n- **Forms**: Formik + Yup validation\n- **Styling**: Tailwind CSS\n- **Security**: BcryptJS password hashing\n\n## 📂 Project Structure\n\n```\n├── app/\n│   ├── api/auth/[...nextauth]/route.ts\n│   └── (auth)/\n├── components/\n│   └── Auth/\n├── models/\n│   └── User.ts\n├── lib/\n│   └── mongoose.ts\n└── types/\n    └── next-auth.d.ts\n```\n\n## 🛠️ MongoDB Setup\n\n1. Create a free cluster at [MongoDB Atlas](https://www.mongodb.com/atlas/database).\n2. Get your connection string:\n\n```env\nMONGODB_URI=\"mongodb+srv://\u003cuser\u003e:\u003cpassword\u003e@cluster.mongodb.net/dbname?retryWrites=true\u0026w=majority\"\n```\n\n## 🔐 Google OAuth Setup\n\n1. Go to [Google Cloud Console](https://console.cloud.google.com/).\n2. Create OAuth 2.0 credentials.\n3. Add the authorized redirect URI:\n\n```\nhttp://localhost:3000/api/auth/callback/google\n```\n\n## 🧩 TypeScript Models\n\n### `models/User.ts`\n\n```typescript\nimport { Schema, model } from 'mongoose';\n\nconst UserSchema = new Schema({\n  name: { type: String },\n  email: { type: String, unique: true },\n  password: { type: String, select: false },\n  role: { type: String, enum: ['user', 'admin'], default: 'user' },\n  emailVerified: { type: Date, default: null },\n}, { timestamps: true });\n\nexport const User = model('User', UserSchema);\n```\n\n## 🚨 Security Features\n\n- Password hashing with bcryptjs\n- CSRF protection\n- HTTPS-only cookies\n- Secure session management\n- Environment variable validation\n- Type-safe API routes\n\n## 📦 Deployment\n\n### Vercel\n\n1. Set environment variables in project settings.\n2. Add the build command: `npm run build`.\n3. Enable Serverless Functions.\n\n### Netlify\n\n```yaml\n# netlify.toml\n[build]\n  command = \"npm run build\"\n  publish = \".next\"\n```\n\n## 💡 Usage Tips\n\n- Customize the sign-in page in `app/(auth)/login/page.tsx`.\n- Add more OAuth providers in `[...nextauth]/route.ts`.\n- Extend the User model with additional fields.\n- Use `getServerSession()` for server-side authentication.\n- Implement rate limiting for authentication endpoints.\n\n---\n\n**Keywords**: Next.js Authentication, MongoDB Auth, NextAuth v5 Tutorial, React 19 Starter, TypeScript Auth Template, Mongoose User Model, Google OAuth Integration, Secure Login System\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdharmveer97%2Fnext-auth-mongoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdharmveer97%2Fnext-auth-mongoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdharmveer97%2Fnext-auth-mongoose/lists"}