├── .eslintrc.json ├── .gitignore ├── README.md ├── components.json ├── global.d.ts ├── next.config.mjs ├── package-lock.json ├── package.json ├── postcss.config.mjs ├── prisma └── schema.prisma ├── public ├── next.svg ├── screenshots │ ├── email_signin.png │ ├── home.png │ ├── intercepting_modal.png │ ├── login.png │ ├── signin.png │ └── signup_modal.png └── vercel.svg ├── src ├── app │ ├── (protected-routes) │ │ ├── dashboard │ │ │ └── page.tsx │ │ └── signout │ │ │ └── page.tsx │ ├── _fonts.ts │ ├── _fonts │ │ └── fonts.ts │ ├── api │ │ └── auth │ │ │ └── [...nextAuth] │ │ │ └── route.ts │ ├── auth-error │ │ └── page.tsx │ ├── auth │ │ ├── email_verify │ │ │ └── page.tsx │ │ ├── forgot-password │ │ │ └── page.tsx │ │ ├── layout.tsx │ │ ├── new-password │ │ │ └── page.tsx │ │ ├── signin │ │ │ └── page.tsx │ │ ├── signup │ │ │ └── page.tsx │ │ └── verify-request │ │ │ └── page.tsx │ ├── favicon.ico │ ├── globals.css │ ├── home │ │ ├── @auth │ │ │ ├── (..)auth │ │ │ │ ├── forgot-password │ │ │ │ │ └── page.tsx │ │ │ │ ├── layout.tsx │ │ │ │ ├── signin │ │ │ │ │ └── page.tsx │ │ │ │ └── signup │ │ │ │ │ └── page.tsx │ │ │ └── default.tsx │ │ ├── layout.tsx │ │ └── page.tsx │ └── layout.tsx ├── assets │ ├── Helvetica-Bold.woff │ ├── Helvetica-Oblique.woff │ ├── Helvetica.woff │ ├── PlaywriteCU-VariableFont_wght.ttf │ └── auth-image-3d-cartoon.jpg ├── auth.ts ├── components │ ├── Modal.tsx │ ├── Spinner.tsx │ ├── ThemeSwitch.tsx │ └── ui │ │ ├── button.tsx │ │ ├── dialog.tsx │ │ ├── dropdown-menu.tsx │ │ ├── form.tsx │ │ ├── input.tsx │ │ ├── label.tsx │ │ ├── sonner.tsx │ │ ├── toast.tsx │ │ ├── toaster.tsx │ │ └── tooltip.tsx ├── constants.ts ├── hooks │ ├── use-toast.ts │ ├── useDebounce.tsx │ ├── useFormSubmit.tsx │ └── useUpdateQueryParams.tsx ├── lib │ ├── db.ts │ ├── fetch.ts │ ├── utils.ts │ └── validate-utils.ts ├── middleware.ts ├── modules │ └── auth │ │ ├── auth.config.ts │ │ ├── auth.schema.ts │ │ ├── auth.ts │ │ ├── components │ │ ├── AuthProvidersCTA.tsx │ │ ├── CaptchaProvider.tsx │ │ ├── EmailVerifyForm.tsx │ │ ├── ForgotPassword.tsx │ │ ├── FormFeedback.tsx │ │ ├── MagicLinkSignin.tsx │ │ ├── NewPasswordForm.tsx │ │ ├── SignInForm.tsx │ │ ├── SignOutButton.tsx │ │ └── SignupForm.tsx │ │ ├── data │ │ ├── index.ts │ │ ├── resetpassword-token.ts │ │ ├── user.ts │ │ └── verification-token.ts │ │ ├── icons.tsx │ │ ├── lib │ │ ├── common.ts │ │ ├── emailVerifyAction.ts │ │ ├── forgot-password.ts │ │ ├── index.ts │ │ ├── recaptcha.ts │ │ ├── signin-action.ts │ │ ├── signin_magic-action.ts │ │ └── signup-action.ts │ │ ├── sendRequest.ts │ │ ├── services │ │ ├── mail.sender.ts │ │ ├── template-service.ts │ │ └── templates │ │ │ ├── reset-password.html │ │ │ └── verification.html │ │ ├── types │ │ ├── auth.d.ts │ │ └── captcha.ts │ │ └── useAuthProviders.tsx ├── providers │ ├── ThemeProvider.tsx │ └── index.tsx ├── routes.ts └── types │ └── types.ts ├── tailwind.config.ts └── tsconfig.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | <<<<<<< HEAD 31 | .env* 32 | ======= 33 | .env 34 | >>>>>>> 35a2b12 (updated readme) 35 | # vercel 36 | .vercel 37 | 38 | # typescript 39 | *.tsbuildinfo 40 | next-env.d.ts 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NextAuth Starter 2 | 3 | A robust authentication solution for Next.js applications, leveraging NextAuth with custom enhancements like RBAC, multi-provider support, and email handling. 4 | 5 | ## Tools and Adapters Used 6 | 7 | - **Next.js** 8 | - **TypeScript** 9 | - **Auth.js (v5)** 10 | - **PostgreSQL** 11 | - **Prisma** 12 | 13 | ## Getting Started 14 | 15 | ### Installation 16 | 17 | ```bash 18 | git clone https://github.com/codersaadi/next-auth5-shadcn.git 19 | cd next-auth5-shadcn 20 | pnpm install 21 | ``` 22 | 23 | ## Setup & Configuration 24 | 25 | Create a .env file in the root directory and add the following configuration: 26 | 27 | ``` 28 | DB_URL="postgresql://dbuser:password@localhost:5432/dbname" 29 | 30 | AUTH_SECRET="your-secret" 31 | 32 | GITHUB_CLIENT_ID="your-client-id" 33 | GITHUB_CLIENT_SECRET="your-client-secret" 34 | 35 | GOOGLE_CLIENT_ID="your-client-id" 36 | GOOGLE_CLIENT_SECRET="your-client-secret" 37 | 38 | FACEBOOK_CLIENT_ID="your-client-id" 39 | FACEBOOK_CLIENT_SECRET="your-client-secret" 40 | 41 | GMAIL_SENDER_EMAIL="your-app-gmail" 42 | GMAIL_SENDER_PASSWORD="gmail-app-password" 43 | 44 | HOST="http://localhost:3000" 45 | 46 | NEXT_PUBLIC_RECAPTCHA_SITE_KEY : "" 47 | RECAPTCHA_SECRET : "" 48 | ``` 49 | 50 | ## Features 51 | 52 | Credential-Based Authentication 53 | -Sign-In, Sign-Up, and Forgot Password functionality. 54 | Custom email templates for password recovery and account verification using Nodemailer. 55 | OAuth Providers 56 | 57 | - Google and Facebook authentication for seamless social logins. 58 | Role-Based Access Control (RBAC) 59 | 60 | - Define user roles and permissions with Prisma for secure access management. 61 | Google Captcha V3 62 | - useFormSubmit Hooks supports the google captcha v3 just pass captcha options , and use reCaptchaSiteVerify in your action. 63 | Database Integration 64 | - Built with Prisma and PostgreSQL for powerful and scalable database interactions. 65 | Schema Validation 66 | - Validate user inputs and responses using Zod. 67 | TypeScript Integration 68 | - Type-safe development with TypeScript, ensuring robust and maintainable code. 69 | Customizable UI 70 | - Tailor the UI components with Shadcn UI, allowing for easy styling adjustments. 71 | Contributions 72 | - Feel free to contribute—contributions are always appreciated! 73 | 74 | # ScreenShots 75 | 76 | ### Home Page 77 | 78 | ![Home Page](public/screenshots/home.png) 79 | 80 | ### Login Page 81 | 82 | ![Login Page](public/screenshots/login.png) 83 | 84 | ### Sign In Page 85 | 86 | ![Sign In Page](public/screenshots/signin.png) 87 | 88 | ### Email Sign In 89 | 90 | ![Email Sign In](public/screenshots/email_signin.png) 91 | 92 | ### Signup Modal 93 | 94 | ![Signup Modal](public/screenshots/signup_modal.png) 95 | 96 | ### Intercepting Modal 97 | 98 | ![Intercepting Modal](public/screenshots/intercepting_modal.png) 99 | 100 | ### Enhancements: 101 | 102 | - **Clearer Section Headers:** Sections are clearly separated for easy navigation. 103 | - **Enhanced Setup Instructions:** The environment setup is clearly outlined. 104 | - **Organized Screenshots:** The screenshots are presented in a clean and structured manner. 105 | - **Features Detailed:** Each feature is highlighted with bold titles for quick reference. 106 | - **Encouragement to Contribute:** The contributions section is friendly and welcoming. 107 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "src/app/globals.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils" 16 | } 17 | } -------------------------------------------------------------------------------- /global.d.ts: -------------------------------------------------------------------------------- 1 | namespace NodeJS { 2 | interface ProcessEnv { 3 | GOOGLE_API_AI_KEY: string; 4 | GITHUB_CLIENT_ID : string; 5 | GITHUB_CLIENT_SECRET : string; 6 | GOOGLE_CLIENT_ID : string; 7 | GOOGLE_CLIENT_SECRET : string; 8 | DB_URL : string; 9 | AUTH_SECRET : string; 10 | GMAIL_SENDER_EMAIL : string; 11 | GMAIL_SENDER_PASSWORD : string; 12 | HOST : string; 13 | FACEBOOK_CLIENT_ID : string 14 | FACEBOOK_CLIENT_SECRET : string 15 | NEXT_PUBLIC_RECAPTCHA_SITE_KEY : string 16 | RECAPTCHA_SECRET : string 17 | } 18 | } -------------------------------------------------------------------------------- /next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | images :{ 4 | // Should be used according to your needs 5 | remotePatterns : [{"hostname" :"**", pathname:"**"}] 6 | } 7 | }; 8 | 9 | export default nextConfig; 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@auth/prisma-adapter": "^2.4.2", 13 | "@hookform/resolvers": "^3.9.0", 14 | "@prisma/client": "^5.19.0", 15 | "@radix-ui/react-dialog": "^1.1.1", 16 | "@radix-ui/react-dropdown-menu": "^2.1.1", 17 | "@radix-ui/react-icons": "^1.3.0", 18 | "@radix-ui/react-label": "^2.1.0", 19 | "@radix-ui/react-slot": "^1.1.0", 20 | "@radix-ui/react-toast": "^1.2.1", 21 | "@radix-ui/react-tooltip": "^1.1.2", 22 | "class-variance-authority": "^0.7.0", 23 | "clsx": "^2.1.1", 24 | "next": "14.2.7", 25 | "next-auth": "^5.0.0-beta.20", 26 | "next-themes": "^0.3.0", 27 | "nodemailer": "^6.9.14", 28 | "react": "^18", 29 | "react-dom": "^18", 30 | "react-google-recaptcha-v3": "^1.10.1", 31 | "react-hook-form": "^7.53.0", 32 | "shadcn": "^1.0.0", 33 | "sonner": "^1.5.0", 34 | "tailwind-merge": "^2.5.2", 35 | "tailwindcss-animate": "^1.0.7", 36 | "zod": "^3.23.8" 37 | }, 38 | "devDependencies": { 39 | "@types/bcryptjs": "^2.4.6", 40 | "@types/node": "^20", 41 | "@types/nodemailer": "^6.4.15", 42 | "@types/react": "^18", 43 | "@types/react-dom": "^18", 44 | "@types/uuid": "^10.0.0", 45 | "bcryptjs": "^2.4.3", 46 | "eslint": "^8", 47 | "eslint-config-next": "14.2.7", 48 | "postcss": "^8", 49 | "prisma": "^5.19.0", 50 | "tailwindcss": "^3.4.1", 51 | "typescript": "^5", 52 | "uuid": "^10.0.0" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // Prisma schema file 2 | 3 | datasource db { 4 | provider = "postgresql" 5 | url = env("DB_URL") 6 | } 7 | 8 | generator client { 9 | provider = "prisma-client-js" 10 | // previewFeatures = ["driverAdapters"] 11 | } 12 | 13 | enum UserRole { 14 | ADMIN 15 | USER 16 | SUPPORT 17 | } 18 | 19 | model User { 20 | id String @id @default(cuid()) 21 | name String? 22 | email String @unique 23 | emailVerified DateTime? 24 | password String? 25 | image String? 26 | role UserRole @default(USER) 27 | accounts Account[] 28 | sessions Session[] 29 | createdAt DateTime @default(now()) 30 | updatedAt DateTime @updatedAt 31 | } 32 | 33 | 34 | model Account { 35 | userId String 36 | type String 37 | provider String 38 | providerAccountId String 39 | refresh_token String? 40 | access_token String? 41 | expires_at Int? 42 | token_type String? 43 | scope String? 44 | id_token String? 45 | session_state String? 46 | createdAt DateTime @default(now()) 47 | updatedAt DateTime @updatedAt 48 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 49 | @@id([provider, providerAccountId]) 50 | } 51 | 52 | model Session { 53 | sessionToken String @unique 54 | userId String 55 | expires DateTime 56 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 57 | createdAt DateTime @default(now()) 58 | updatedAt DateTime @updatedAt 59 | } 60 | 61 | model VerificationToken { 62 | identifier String 63 | token String 64 | expires DateTime 65 | @@id([identifier, token]) 66 | } 67 | 68 | model ResetPasswordToken { 69 | id String @id @default(cuid()) 70 | email String 71 | token String @unique 72 | expires DateTime 73 | 74 | @@unique([email, token]) 75 | } 76 | -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/screenshots/email_signin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/public/screenshots/email_signin.png -------------------------------------------------------------------------------- /public/screenshots/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/public/screenshots/home.png -------------------------------------------------------------------------------- /public/screenshots/intercepting_modal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/public/screenshots/intercepting_modal.png -------------------------------------------------------------------------------- /public/screenshots/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/public/screenshots/login.png -------------------------------------------------------------------------------- /public/screenshots/signin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/public/screenshots/signin.png -------------------------------------------------------------------------------- /public/screenshots/signup_modal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/public/screenshots/signup_modal.png -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/(protected-routes)/dashboard/page.tsx: -------------------------------------------------------------------------------- 1 | import { auth } from '@/auth' 2 | import SignOutButton from '@/modules/auth/components/SignOutButton' 3 | import { AvatarIcon } from '@radix-ui/react-icons' 4 | import React from 'react' 5 | 6 | export default async function page() { 7 | const session = await auth() 8 | 9 | return ( 10 | <> 11 |
12 |       {
13 |         JSON.stringify(session, null, 2)
14 |       }
15 |     
16 | 17 | 18 | ) 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/app/(protected-routes)/signout/page.tsx: -------------------------------------------------------------------------------- 1 | import { signOut } from "@/auth"; 2 | 3 | export default function SignOutPage() { 4 | return ( 5 |
6 |
7 |
8 | Are you sure you want to sign out? 9 |
10 |
{ 12 | "use server"; 13 | await signOut(); 14 | }} 15 | className="flex flex-col space-y-4" 16 | > 17 | 23 | 27 | Cancel 28 | 29 |
30 |
31 |
32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /src/app/_fonts.ts: -------------------------------------------------------------------------------- 1 | import { Roboto_Serif } from "next/font/google"; 2 | const inter = Roboto_Serif({ subsets: ["latin"] , variable : "--font-robo-serif"}); 3 | 4 | const fonts = { 5 | inter, 6 | }; 7 | export default fonts; 8 | -------------------------------------------------------------------------------- /src/app/_fonts/fonts.ts: -------------------------------------------------------------------------------- 1 | import { Open_Sans, Roboto_Flex, } from "next/font/google"; 2 | const inter = Open_Sans({ subsets: ["latin"] , variable : "--font-sans"}); 3 | import localFont from 'next/font/local'; 4 | const hvFont = localFont({ 5 | src : [ 6 | { 7 | path : "../../assets/Helvetica.woff", 8 | weight: '400', 9 | style: 'normal', 10 | }, 11 | { 12 | path : "../../assets/Helvetica-Bold.woff", 13 | weight: '600', 14 | style: 'normal', 15 | }, 16 | 17 | ] 18 | }) 19 | const fonts = { 20 | inter,hvFont 21 | }; 22 | export default fonts; 23 | -------------------------------------------------------------------------------- /src/app/api/auth/[...nextAuth]/route.ts: -------------------------------------------------------------------------------- 1 | import { handlers } from "@/auth" 2 | export const { GET, POST } = handlers -------------------------------------------------------------------------------- /src/app/auth-error/page.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | 4 | enum Error { 5 | Configuration = "Configuration", 6 | AccessDenied = "AccessDenied", 7 | Verification = "Verification", 8 | Default = "Default", 9 | } 10 | 11 | const errorMap = { 12 | [Error.Configuration]: ( 13 |

14 | There was a problem when trying to authenticate. Please contact us if this 15 | error persists. Unique error code:{" "} 16 | 17 | Configuration 18 | 19 |

20 | ), 21 | [Error.AccessDenied]: ( 22 |

23 | Access was denied. If you believe this is an error, please contact support. 24 | Unique error code:{" "} 25 | 26 | AccessDenied 27 | 28 |

29 | ), 30 | [Error.Verification]: ( 31 |

32 | The verification link has expired or was already used. Please request a new one. 33 | Unique error code:{" "} 34 | 35 | Verification 36 | 37 |

38 | ), 39 | [Error.Default]: ( 40 |

41 | An unexpected error occurred. Please try again later or contact support. 42 | Unique error code:{" "} 43 | 44 | Default 45 | 46 |

47 | ), 48 | }; 49 | 50 | export default function AuthErrorPage({searchParams} :{ 51 | searchParams : any 52 | }) { 53 | const error = searchParams["error"] as Error; 54 | 55 | return ( 56 |
57 |
58 |

59 | Oops! Something went wrong 60 |

61 |
62 | {errorMap[error] || errorMap[Error.Default]} 63 |
64 | 68 | Go to Homepage 69 | 70 |
71 |
72 | ); 73 | } 74 | -------------------------------------------------------------------------------- /src/app/auth/email_verify/page.tsx: -------------------------------------------------------------------------------- 1 | import EmailVerifyForm from '@/modules/auth/components/EmailVerifyForm' 2 | import React from 'react' 3 | 4 | interface EmailVerifyProps { 5 | searchParams : { 6 | token? : string 7 | } 8 | } 9 | 10 | export default function page({searchParams} : EmailVerifyProps) { 11 | const {token } = searchParams 12 | 13 | return ( 14 | 15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /src/app/auth/forgot-password/page.tsx: -------------------------------------------------------------------------------- 1 | import ForgotPasswordForm from "@/modules/auth/components/ForgotPassword"; 2 | export default ForgotPasswordForm -------------------------------------------------------------------------------- /src/app/auth/layout.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import CaptchaClientProvider from '@/modules/auth/components/CaptchaProvider'; 3 | import React, { useState } from 'react'; 4 | import authImage from '@/assets/auth-image-3d-cartoon.jpg' 5 | import Image from 'next/image'; 6 | const AuthLayout = ({ children }: { children: React.ReactNode }) => { 7 | const [loading , setLoading] = useState(true) 8 | const layoutComponent = ( 9 |
10 |
11 |
12 |

13 | Welcome Back to X-UI 14 |

15 |

Everything should have a good start.

16 | 17 |
18 | {children} 19 |
20 |
21 |
22 | moon-3d-image-cartoon setLoading(false)} quality={75} className={`w-full h-full object-cover ${loading && "blur"}`}/> 23 |
24 |
25 | ) 26 | return ( 27 | 28 | {layoutComponent} 29 | 30 | ); 31 | }; 32 | 33 | export default AuthLayout; 34 | -------------------------------------------------------------------------------- /src/app/auth/new-password/page.tsx: -------------------------------------------------------------------------------- 1 | import NewPasswordForm from '@/modules/auth/components/NewPasswordForm' 2 | import React from 'react' 3 | interface ResetPasswordProps { 4 | searchParams : { 5 | token? : string 6 | } 7 | } 8 | 9 | export default function page({searchParams} : ResetPasswordProps) { 10 | const {token } = searchParams 11 | 12 | return ( 13 | 14 | ) 15 | } 16 | -------------------------------------------------------------------------------- /src/app/auth/signin/page.tsx: -------------------------------------------------------------------------------- 1 | import { Metadata } from "next"; 2 | import SignInForm from "@/modules/auth/components/SignInForm"; 3 | export default SignInForm 4 | 5 | /** 6 | * Meta data for the signin form page 7 | */ 8 | export const metadata: Metadata = { 9 | title: 'AppName - Signin to Continue ', 10 | description: '...', 11 | } -------------------------------------------------------------------------------- /src/app/auth/signup/page.tsx: -------------------------------------------------------------------------------- 1 | import SignUpForm from "@/modules/auth/components/SignupForm"; 2 | export default SignUpForm 3 | 4 | import { Metadata } from "next"; 5 | 6 | /** 7 | * Meta data for the signin form page 8 | */ 9 | export const metadata: Metadata= { 10 | title: 'AppName -Create an Account for free ', 11 | description: '...', 12 | } -------------------------------------------------------------------------------- /src/app/auth/verify-request/page.tsx: -------------------------------------------------------------------------------- 1 | import { logoUrl } from "@/constants"; 2 | import Image from "next/image"; 3 | import Link from "next/link"; 4 | 5 | const VerifyRequest = ({searchParams} :{ 6 | searchParams : Record 7 | }) => { 8 | const email = searchParams?.email 9 | 10 | return ( 11 |
12 |
13 |
14 | Your Company 19 |

20 | Check your email 21 |

22 |

23 | We have sent a sign-in link to your email address. {email && ( 24 | {email} 25 | )} 26 |

27 |
28 |
29 |
30 |
31 | 34 | Back to Sign In 35 | 36 |
37 |
38 |
39 |
40 |
41 | ); 42 | }; 43 | 44 | export default VerifyRequest; 45 | -------------------------------------------------------------------------------- /src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/src/app/favicon.ico -------------------------------------------------------------------------------- /src/app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | @layer base { 6 | :root { 7 | --background: 0 0% 100%; 8 | --foreground: 0 0% 3.9%; 9 | --card: 0 0% 100%; 10 | --card-foreground: 0 0% 3.9%; 11 | --popover: 0 0% 100%; 12 | --popover-foreground: 0 0% 3.9%; 13 | --primary: 0 0% 9%; 14 | --primary-foreground: 0 0% 98%; 15 | --secondary: 0 0% 96.1%; 16 | --secondary-foreground: 0 0% 9%; 17 | --muted: 0 0% 96.1%; 18 | --muted-foreground: 0 0% 45.1%; 19 | --accent: 0 0% 96.1%; 20 | --accent-foreground: 0 0% 9%; 21 | --destructive: 0 84.2% 60.2%; 22 | --destructive-foreground: 0 0% 98%; 23 | --border: 0 0% 89.8%; 24 | --input: 0 0% 89.8%; 25 | --ring: 0 0% 3.9%; 26 | --radius: 0.5rem; 27 | --chart-1: 12 76% 61%; 28 | --chart-2: 173 58% 39%; 29 | --chart-3: 197 37% 24%; 30 | --chart-4: 43 74% 66%; 31 | --chart-5: 27 87% 67%; 32 | } 33 | 34 | .dark { 35 | --background: 0 0% 3.9%; 36 | --foreground: 0 0% 98%; 37 | --card: 0 0% 3.9%; 38 | --card-foreground: 0 0% 98%; 39 | --popover: 0 0% 3.9%; 40 | --popover-foreground: 0 0% 98%; 41 | --primary: 0 0% 98%; 42 | --primary-foreground: 0 0% 9%; 43 | --secondary: 0 0% 14.9%; 44 | --secondary-foreground: 0 0% 98%; 45 | --muted: 0 0% 14.9%; 46 | --muted-foreground: 0 0% 63.9%; 47 | --accent: 0 0% 14.9%; 48 | --accent-foreground: 0 0% 98%; 49 | --destructive: 0 62.8% 30.6%; 50 | --destructive-foreground: 0 0% 98%; 51 | --border: 0 0% 14.9%; 52 | --input: 0 0% 14.9%; 53 | --ring: 0 0% 83.1%; 54 | --chart-1: 220 70% 50%; 55 | --chart-2: 160 60% 45%; 56 | --chart-3: 30 80% 55%; 57 | --chart-4: 280 65% 60%; 58 | --chart-5: 340 75% 55%; 59 | } 60 | } 61 | 62 | @layer base { 63 | * { 64 | @apply border-border; 65 | } 66 | body { 67 | @apply bg-background text-foreground; 68 | } 69 | } -------------------------------------------------------------------------------- /src/app/home/@auth/(..)auth/forgot-password/page.tsx: -------------------------------------------------------------------------------- 1 | import ForgotPasswordForm from "@/modules/auth/components/ForgotPassword"; 2 | 3 | export default ForgotPasswordForm; -------------------------------------------------------------------------------- /src/app/home/@auth/(..)auth/layout.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import Modal from '@/components/Modal' 3 | import CaptchaClientProvider from '@/modules/auth/components/CaptchaProvider' 4 | import React from 'react' 5 | 6 | export default function AuthModalLayout({children} :{ 7 | children: React.ReactNode, 8 | }) { 9 | 10 | return ( 11 | 12 | 13 | {children} 14 | 15 | 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /src/app/home/@auth/(..)auth/signin/page.tsx: -------------------------------------------------------------------------------- 1 | import SignInForm from "@/modules/auth/components/SignInForm"; 2 | 3 | export default SignInForm 4 | -------------------------------------------------------------------------------- /src/app/home/@auth/(..)auth/signup/page.tsx: -------------------------------------------------------------------------------- 1 | import SignUpForm from "@/modules/auth/components/SignupForm"; 2 | 3 | export default SignUpForm -------------------------------------------------------------------------------- /src/app/home/@auth/default.tsx: -------------------------------------------------------------------------------- 1 | 2 | export default function Default() { 3 | return null 4 | } 5 | -------------------------------------------------------------------------------- /src/app/home/layout.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default function AppLayout({ 4 | children, 5 | auth 6 | }: { 7 | children: React.ReactNode; 8 | auth: React.ReactNode; 9 | }) { 10 | return ( 11 | <> 12 | {auth} 13 | {children} 14 | 15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /src/app/home/page.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from "@/components/ui/button"; 2 | import Image from "next/image"; 3 | import Link from "next/link"; 4 | 5 | export default function Home() { 6 | return ( 7 |
8 |
9 |

10 | Get started by editing  11 | src/app/page.tsx 12 |

13 | 31 |
32 |
33 | 34 | 37 | 38 | 39 | 42 | 43 |
44 |
45 | Next.js Logo 53 | 54 |

55 | With 56 | Auth.js 57 |

58 |
59 | 60 | 129 |
130 | ); 131 | } 132 | -------------------------------------------------------------------------------- /src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | import "./globals.css" 3 | import fonts from './_fonts/fonts' 4 | import Provider from "@/providers"; 5 | import { ThemeSwitch } from "@/components/ThemeSwitch"; 6 | import React from 'react' 7 | import { Toaster } from "@/components/ui/toaster"; 8 | export const metadata: Metadata = { 9 | title: "Create Next App", 10 | description: "Generated by create next app", 11 | }; 12 | 13 | export default function RootLayout({ 14 | children, 15 | }: { 16 | children: React.ReactNode; 17 | }) { 18 | return ( 19 | 20 | 23 | 24 | 25 |
26 | 27 |
28 | {children} 29 |
30 | 31 | 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /src/assets/Helvetica-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/src/assets/Helvetica-Bold.woff -------------------------------------------------------------------------------- /src/assets/Helvetica-Oblique.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/src/assets/Helvetica-Oblique.woff -------------------------------------------------------------------------------- /src/assets/Helvetica.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/src/assets/Helvetica.woff -------------------------------------------------------------------------------- /src/assets/PlaywriteCU-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/src/assets/PlaywriteCU-VariableFont_wght.ttf -------------------------------------------------------------------------------- /src/assets/auth-image-3d-cartoon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codersaadi/next-auth5-shadcn/bec70b4a330b4212f774b5f7c7ef68f02f43b10e/src/assets/auth-image-3d-cartoon.jpg -------------------------------------------------------------------------------- /src/auth.ts: -------------------------------------------------------------------------------- 1 | import { nextAuth } from "./modules/auth/auth"; 2 | export const { handlers, signIn, signOut, auth } = nextAuth 3 | -------------------------------------------------------------------------------- /src/components/Modal.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | import React from 'react' 3 | import { Dialog, DialogOverlay, DialogContent } from '@/components/ui/dialog' 4 | import { useRouter } from 'next/navigation' 5 | export default function Modal({ 6 | children 7 | } :{ 8 | children: React.ReactNode 9 | }) { 10 | const router = useRouter() 11 | function handleOpenChange() { 12 | router.back() 13 | } 14 | return ( 15 | 16 | 17 | 18 | {children} 19 | 20 | 21 | 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /src/components/Spinner.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils' 2 | import React from 'react' 3 | 4 | export const LoadingSpinner = ({className} :{ 5 | className?: string 6 | }) => { 7 | return 19 | 20 | 21 | 22 | } -------------------------------------------------------------------------------- /src/components/ThemeSwitch.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { MoonIcon, SunIcon } from '@radix-ui/react-icons' 3 | import { useTheme } from 'next-themes' 4 | import Image from 'next/image' 5 | import React, { useEffect } from 'react' 6 | export function ThemeSwitch() { 7 | const DARK_THEME = 'dark' 8 | const LIGHT_THEME = 'light' 9 | const [mounted, setMounted] = React.useState(false) 10 | const {setTheme, resolvedTheme} = useTheme() 11 | useEffect(()=> setMounted(true), []) 12 | if (!mounted) { 13 | return Loading Light/Dark Toggle 22 | } 23 | if (resolvedTheme === DARK_THEME) { 24 | return setTheme(LIGHT_THEME)}/> 25 | } 26 | if (resolvedTheme === LIGHT_THEME) { 27 | return setTheme(DARK_THEME)}/> 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/components/ui/button.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Slot } from "@radix-ui/react-slot" 3 | import { cva, type VariantProps } from "class-variance-authority" 4 | 5 | import { cn } from "@/lib/utils" 6 | 7 | const buttonVariants = cva( 8 | "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", 9 | { 10 | variants: { 11 | variant: { 12 | default: 13 | "bg-primary text-primary-foreground shadow hover:bg-primary/90", 14 | destructive: 15 | "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", 16 | outline: 17 | "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", 18 | secondary: 19 | "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", 20 | ghost: "hover:bg-accent hover:text-accent-foreground", 21 | link: "text-primary underline-offset-4 hover:underline", 22 | }, 23 | size: { 24 | default: "h-9 px-4 py-2", 25 | sm: "h-8 rounded-md px-3 text-xs", 26 | lg: "h-10 rounded-md px-8", 27 | icon: "h-9 w-9", 28 | }, 29 | }, 30 | defaultVariants: { 31 | variant: "default", 32 | size: "default", 33 | }, 34 | } 35 | ) 36 | 37 | export interface ButtonProps 38 | extends React.ButtonHTMLAttributes, 39 | VariantProps { 40 | asChild?: boolean 41 | } 42 | 43 | const Button = React.forwardRef( 44 | ({ className, variant, size, asChild = false, ...props }, ref) => { 45 | const Comp = asChild ? Slot : "button" 46 | return ( 47 | 52 | ) 53 | } 54 | ) 55 | Button.displayName = "Button" 56 | 57 | export { Button, buttonVariants } 58 | -------------------------------------------------------------------------------- /src/components/ui/dialog.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as DialogPrimitive from "@radix-ui/react-dialog" 5 | import { Cross2Icon } from "@radix-ui/react-icons" 6 | 7 | import { cn } from "@/lib/utils" 8 | 9 | const Dialog = DialogPrimitive.Root 10 | 11 | const DialogTrigger = DialogPrimitive.Trigger 12 | 13 | const DialogPortal = DialogPrimitive.Portal 14 | 15 | const DialogClose = DialogPrimitive.Close 16 | 17 | const DialogOverlay = React.forwardRef< 18 | React.ElementRef, 19 | React.ComponentPropsWithoutRef 20 | >(({ className, ...props }, ref) => ( 21 | 29 | )) 30 | DialogOverlay.displayName = DialogPrimitive.Overlay.displayName 31 | 32 | const DialogContent = React.forwardRef< 33 | React.ElementRef, 34 | React.ComponentPropsWithoutRef 35 | >(({ className, children, ...props }, ref) => ( 36 | 37 | 38 | 46 | {children} 47 | 48 | 49 | Close 50 | 51 | 52 | 53 | )) 54 | DialogContent.displayName = DialogPrimitive.Content.displayName 55 | 56 | const DialogHeader = ({ 57 | className, 58 | ...props 59 | }: React.HTMLAttributes) => ( 60 |
67 | ) 68 | DialogHeader.displayName = "DialogHeader" 69 | 70 | const DialogFooter = ({ 71 | className, 72 | ...props 73 | }: React.HTMLAttributes) => ( 74 |
81 | ) 82 | DialogFooter.displayName = "DialogFooter" 83 | 84 | const DialogTitle = React.forwardRef< 85 | React.ElementRef, 86 | React.ComponentPropsWithoutRef 87 | >(({ className, ...props }, ref) => ( 88 | 96 | )) 97 | DialogTitle.displayName = DialogPrimitive.Title.displayName 98 | 99 | const DialogDescription = React.forwardRef< 100 | React.ElementRef, 101 | React.ComponentPropsWithoutRef 102 | >(({ className, ...props }, ref) => ( 103 | 108 | )) 109 | DialogDescription.displayName = DialogPrimitive.Description.displayName 110 | 111 | export { 112 | Dialog, 113 | DialogPortal, 114 | DialogOverlay, 115 | DialogTrigger, 116 | DialogClose, 117 | DialogContent, 118 | DialogHeader, 119 | DialogFooter, 120 | DialogTitle, 121 | DialogDescription, 122 | } 123 | -------------------------------------------------------------------------------- /src/components/ui/dropdown-menu.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" 5 | import { 6 | CheckIcon, 7 | ChevronRightIcon, 8 | DotFilledIcon, 9 | } from "@radix-ui/react-icons" 10 | 11 | import { cn } from "@/lib/utils" 12 | 13 | const DropdownMenu = DropdownMenuPrimitive.Root 14 | 15 | const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger 16 | 17 | const DropdownMenuGroup = DropdownMenuPrimitive.Group 18 | 19 | const DropdownMenuPortal = DropdownMenuPrimitive.Portal 20 | 21 | const DropdownMenuSub = DropdownMenuPrimitive.Sub 22 | 23 | const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup 24 | 25 | const DropdownMenuSubTrigger = React.forwardRef< 26 | React.ElementRef, 27 | React.ComponentPropsWithoutRef & { 28 | inset?: boolean 29 | } 30 | >(({ className, inset, children, ...props }, ref) => ( 31 | 40 | {children} 41 | 42 | 43 | )) 44 | DropdownMenuSubTrigger.displayName = 45 | DropdownMenuPrimitive.SubTrigger.displayName 46 | 47 | const DropdownMenuSubContent = React.forwardRef< 48 | React.ElementRef, 49 | React.ComponentPropsWithoutRef 50 | >(({ className, ...props }, ref) => ( 51 | 59 | )) 60 | DropdownMenuSubContent.displayName = 61 | DropdownMenuPrimitive.SubContent.displayName 62 | 63 | const DropdownMenuContent = React.forwardRef< 64 | React.ElementRef, 65 | React.ComponentPropsWithoutRef 66 | >(({ className, sideOffset = 4, ...props }, ref) => ( 67 | 68 | 78 | 79 | )) 80 | DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName 81 | 82 | const DropdownMenuItem = React.forwardRef< 83 | React.ElementRef, 84 | React.ComponentPropsWithoutRef & { 85 | inset?: boolean 86 | } 87 | >(({ className, inset, ...props }, ref) => ( 88 | 97 | )) 98 | DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName 99 | 100 | const DropdownMenuCheckboxItem = React.forwardRef< 101 | React.ElementRef, 102 | React.ComponentPropsWithoutRef 103 | >(({ className, children, checked, ...props }, ref) => ( 104 | 113 | 114 | 115 | 116 | 117 | 118 | {children} 119 | 120 | )) 121 | DropdownMenuCheckboxItem.displayName = 122 | DropdownMenuPrimitive.CheckboxItem.displayName 123 | 124 | const DropdownMenuRadioItem = React.forwardRef< 125 | React.ElementRef, 126 | React.ComponentPropsWithoutRef 127 | >(({ className, children, ...props }, ref) => ( 128 | 136 | 137 | 138 | 139 | 140 | 141 | {children} 142 | 143 | )) 144 | DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName 145 | 146 | const DropdownMenuLabel = React.forwardRef< 147 | React.ElementRef, 148 | React.ComponentPropsWithoutRef & { 149 | inset?: boolean 150 | } 151 | >(({ className, inset, ...props }, ref) => ( 152 | 161 | )) 162 | DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName 163 | 164 | const DropdownMenuSeparator = React.forwardRef< 165 | React.ElementRef, 166 | React.ComponentPropsWithoutRef 167 | >(({ className, ...props }, ref) => ( 168 | 173 | )) 174 | DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName 175 | 176 | const DropdownMenuShortcut = ({ 177 | className, 178 | ...props 179 | }: React.HTMLAttributes) => { 180 | return ( 181 | 185 | ) 186 | } 187 | DropdownMenuShortcut.displayName = "DropdownMenuShortcut" 188 | 189 | export { 190 | DropdownMenu, 191 | DropdownMenuTrigger, 192 | DropdownMenuContent, 193 | DropdownMenuItem, 194 | DropdownMenuCheckboxItem, 195 | DropdownMenuRadioItem, 196 | DropdownMenuLabel, 197 | DropdownMenuSeparator, 198 | DropdownMenuShortcut, 199 | DropdownMenuGroup, 200 | DropdownMenuPortal, 201 | DropdownMenuSub, 202 | DropdownMenuSubContent, 203 | DropdownMenuSubTrigger, 204 | DropdownMenuRadioGroup, 205 | } 206 | -------------------------------------------------------------------------------- /src/components/ui/form.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as LabelPrimitive from "@radix-ui/react-label" 5 | import { Slot } from "@radix-ui/react-slot" 6 | import { 7 | Controller, 8 | ControllerProps, 9 | FieldPath, 10 | FieldValues, 11 | FormProvider, 12 | useFormContext, 13 | } from "react-hook-form" 14 | 15 | import { cn } from "@/lib/utils" 16 | import { Label } from "@/components/ui/label" 17 | 18 | const Form = FormProvider 19 | 20 | type FormFieldContextValue< 21 | TFieldValues extends FieldValues = FieldValues, 22 | TName extends FieldPath = FieldPath 23 | > = { 24 | name: TName 25 | } 26 | 27 | const FormFieldContext = React.createContext( 28 | {} as FormFieldContextValue 29 | ) 30 | 31 | const FormField = < 32 | TFieldValues extends FieldValues = FieldValues, 33 | TName extends FieldPath = FieldPath 34 | >({ 35 | ...props 36 | }: ControllerProps) => { 37 | return ( 38 | 39 | 40 | 41 | ) 42 | } 43 | 44 | const useFormField = () => { 45 | const fieldContext = React.useContext(FormFieldContext) 46 | const itemContext = React.useContext(FormItemContext) 47 | const { getFieldState, formState } = useFormContext() 48 | 49 | const fieldState = getFieldState(fieldContext.name, formState) 50 | 51 | if (!fieldContext) { 52 | throw new Error("useFormField should be used within ") 53 | } 54 | 55 | const { id } = itemContext 56 | 57 | return { 58 | id, 59 | name: fieldContext.name, 60 | formItemId: `${id}-form-item`, 61 | formDescriptionId: `${id}-form-item-description`, 62 | formMessageId: `${id}-form-item-message`, 63 | ...fieldState, 64 | } 65 | } 66 | 67 | type FormItemContextValue = { 68 | id: string 69 | } 70 | 71 | const FormItemContext = React.createContext( 72 | {} as FormItemContextValue 73 | ) 74 | 75 | const FormItem = React.forwardRef< 76 | HTMLDivElement, 77 | React.HTMLAttributes 78 | >(({ className, ...props }, ref) => { 79 | const id = React.useId() 80 | 81 | return ( 82 | 83 |
84 | 85 | ) 86 | }) 87 | FormItem.displayName = "FormItem" 88 | 89 | const FormLabel = React.forwardRef< 90 | React.ElementRef, 91 | React.ComponentPropsWithoutRef 92 | >(({ className, ...props }, ref) => { 93 | const { error, formItemId } = useFormField() 94 | 95 | return ( 96 |