Use Lucia instead of Next Auth - Lucia Auth Next 14 Username Password Authentication Full Tutorial
Ugur Codes Ugur Codes
927 subscribers
13,516 views
341

 Published On Feb 18, 2024

In this video we will setup a Next js 14 with App directory. We learn how to use Lucia auth package to setup a username, password authentication.

We setup a PostgreSQL Docker container, but you may use your own database if you use a cloud service.

We use Drizzle ORM and learn how can we integrate it with Lucia package.

ShadCN for forms, Zod library for the validation.

and using server components and server actions.

I will add a Google Auth in the next video!

Here is the github repository, I will update this repo with other login types as well, you can take a look at the other branches for other types of login.

https://github.com/ugurkellecioglu/ne...

Don't forget to drop a star! :)

Links:
1. Lucia Docs - https://lucia-auth.com
2. Drizzle Orm - https://orm.drizzle.team/docs/overview
3. ShadCN docs - https://ui.shadcn.com/docs
4. Next Js 14 docs - https://nextjs.org/

00:00 - Demo
00:59 - Initialize a Next 14 App
01:40 - Install Lucia package and thoughts about the package
04:32 - Install Drizzle ORM and configuration
05:45 - Create our database file, schema, adapter.
07:48 - Create a Lucia instance
08:15 - Create a PostgreSQL docker container for .env file
09:42 - Add new scripts into package json for drizzle-kit
09:54 - Fixi Schema.ts issue
11:26 - Create sign-up page
12:30 - Install shadcn package - create a form
16:30 - Create an actions file - signUp function
20:03 - Fix Toast issue
21:50 - Validate session feature
24:43 - Sign in page
26:40 - Fix Drizzle userTable issue
27:05 - Sign in function
29:30 - Fix Sign in error - adapter issue
31:30 - Sign out function
33:05 - Redirect user to root page if they have a sesion and try to go sign-in sign-up pages.
33:55 - Good bye!

show more

Share/Embed