Intermediate~8 hours

Authentication Starter

Add real sign-in to a Next.js app with NextAuth (GitHub + credentials), protected routes, and a database-backed session.

AuthNextAuthMiddleware
1

Install and configure Auth.js

Set up NextAuth with a GitHub provider and the required environment variables.

2

Add a database adapter

Persist users and sessions with the Prisma adapter so logins survive restarts.

3

Protect routes with middleware

Redirect unauthenticated users away from `/dashboard` using `middleware.ts`.

4

Read the session

Show the signed-in user's name and a sign-out button in the navbar.

5

Add credentials login

Support email + password sign-in with hashed passwords and validation.

Finished building?

Ship it and share it in a community challenge — or move on to the next project.