Authentication demo using Next.js and NextAuth.js with GitHub as the OAuth provider.
This is a learning project exploring authentication flows with:
- Next.js 16 (App Router)
- NextAuth.js v4 for OAuth
- GitHub OAuth for authentication
- Tailwind CSS v4 for styling
- TypeScript for type safety
- GitHub OAuth authentication
- Session management
- A GitHub account and Node.js installed on your machine
- Go to GitHub Settings → Developer settings → OAuth Apps
- Click "New OAuth App"
- Fill all the details:
- Application name: as you want
- Homepage URL:
http://localhost:3000 - Authorization callback URL:
http://localhost:3000/api/auth/callback/github
- Save your
Client IDand generate aClient Secret
Create a .env.local file in the root directory:
GITHUB_ID=your_github_client_id_here
GITHUB_CLIENT_SECRET=your_github_client_secret_here
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_random_secret_hereYou can generate a secret with:
openssl rand -base64 32
# Install dependencies
npm install
# Run the dev server
npm run dev- Next.js (App Router), NextAuth.js v4, Tailwind CSS v4, TypeScript and GitHub
- How OAuth 2.0 flows work
- Learned how to setting up NextAuth.js in Next.js
- Managing sessions client-side and server-side
- Creating beautiful, modern UIs with Tailwind
This is a learning project so fork it and make it yours.
This is a fun learning project - do whatever you want with it! MIT License if you need one.