Next-auth 를 이용한 로그인 구현

참고사이트

설명

next-auth라이브러리는 next.js로 이루어진 페이지에서 auth 관련된 역할을 수행하는 라이브러리

사용방법(임시)

npm i [email protected] @auth/core

src폴더에

auth.ts파일 생성

소스코드

서버컴포넌트에서

import {auth} from ‘@/auth’를 통해 사용가능

클라이언트컴포넌트에서

import {useSession} from ‘next-auth/react’;

next-auth는 쿠키해킹공격을 알아서 막아준다.