npm install @nest-hero/next-auth
export const authOptions: NextAuthOptions = {
session: {
strategy: 'jwt',
}
}
import {NextAuthModule} from '@nest-hero/next-auth';
@Module({
imports: [
NextAuthModule.forRoot({
secret: process.env.NEXTAUTH_SECRET,
cookieName: 'optional'
}),
],
})
export class AppModule {}
import { NextAuthGuard, User } from '@nest-hero/next-auth';
@Controller()
export class AppController {
@UseGuards(NextAuthGuard)
@Post('/')
handler(@User() user) {
return user;
}
}
You can check full example (Nest.JS + Next.JS) at /exmaple
folder
- NextAuth jwt strategy
- NextAuth Options Wrapper
- NextAuth session table strategy