Key Features:
- Next.js 14
- Next Auth v5 (Auth.js)
- Credentials Provider
- Protected routes & redirect if logged
- Server Actions
- Forms
- useFormState hook
- Server-side form validation with zod
- Unit and Integration tests
- Complete test setup for Next Auth
- Mocks of server actions and useFormState hook
This repository serves as an example of how to implement an authentication flow with middleware using next-auth v5. this repo also contains the necessary configs to setup a test environment for next-auth v5 using jest/testing-library, also containing examples of how to mock a server action and the useFormState hook.
This repository uses react and react-dom in canary versions.
git clone https://github.com/renanleonel/next-auth-v5-middleware.git
pnpm i
pnpm run dev