Security
Intermediate
Authentication
Implement authentication with NextAuth.js v5 (Auth.js), middleware, and protected routes.
30 min
3 sections
auth
nextauth
security
1
2
3
01. Setting Up NextAuth.js
Section 1 of 3
Configure NextAuth.js v5 with credential and OAuth providers.
typescript
// auth.ts
import NextAuth from 'next-auth';
import Google from 'next-auth/providers/google';
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
Google({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
],
});Exercise
Set Up Basic Auth
Practice
Install NextAuth.js and configure it with a basic credential provider.
Back to Course