Member-only story
Authenticate Next 14 App Router with Lucia Auth
Credential Auth and OAuth Github
10 min readMar 2, 2024
This Post will guide you to Authenticate Next 14 App with Credential (Username and Password) or OAuth Github using Lucia Auth, validate form Register and Login using Zod, save data user to Database using DrizzleORM and Neon.
Prerequisite:
- Next 14
- TailwindCSS
- Neon Database
- Lucia Auth
- Drizzle ORM
- Zod
Installation:
To install this prerequisite run this command
// Next App
npx create-next-app@latest
// Lucia Auth
npm i lucia @lucia-auth/adapter-drizzle arctic oslo postgres
// Drizzle
npm i drizzle-orm
npm i -D drizzle-kit
// Neon Database
npm i @neondatabase/serverless
// Zod and Radix Icon
npm i zod @radix-ui/react-icons
Setting Environment:
- Create new file
.env.local
on the root folder - Create New OAuth Apps Github in here and copy Github ID and Secret Key to
GITHUB_ID
and…