Installation

Get started with the Next.js Authentication Template in just a few minutes.

Requirements

RequirementVersionNotes
Node.js>= 18.17LTS version recommended
npm / pnpm / yarnlatestAny package manager
GitlatestFor cloning the repository

Quick Start

Follow these steps to get the template running locally:

Step 1: Clone the Repository

git clone https://github.com/HieuNT44/next-auth-template.git

Step 2: Install Dependencies

# Using npm
npm install

# Using pnpm
pnpm install

# Using yarn
yarn install

Step 3: Configure Environment

Copy the example environment file and update it with your credentials:

cp .env.example .env.local

Step 4: Start Development Server

npm run dev

Open http://localhost:3000 in your browser to see the application.

Environment Variables

Configure your authentication providers by updating the .env.local file:

NextAuth.js Configuration

VariableDescriptionRequired
NEXTAUTH_SECRETSecret key for encrypting sessionsYes
NEXTAUTH_URLBase URL of your applicationYes

OAuth Providers

ProviderClient IDClient Secret
GoogleGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRET
FacebookFACEBOOK_CLIENT_IDFACEBOOK_CLIENT_SECRET
InstagramINSTAGRAM_CLIENT_IDINSTAGRAM_CLIENT_SECRET
LINELINE_CLIENT_IDLINE_CLIENT_SECRET

Firebase Configuration (Optional)

VariableDescription
NEXT_PUBLIC_FIREBASE_API_KEYFirebase API key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAINFirebase auth domain
NEXT_PUBLIC_FIREBASE_PROJECT_IDFirebase project ID

Available Scripts

CommandDescription
npm run devStart development server
npm run buildBuild for production
npm run startStart production server
npm run lintRun ESLint
npm run formatFormat code with Prettier
npm run testRun tests with Vitest

Next Steps

After installation, explore these guides: