한 auth() 가 어디서든 작동
Auth.js v5 (옛 NextAuth.js) 가 Server Component, Server Action, Route Handler, proxy 에서 도는 단일 auth() helper ship. Mental model: "session 있어?" — 같은 답, 같은 call site, 어디서 묻든.
Setup
next-auth@beta install, provider 설정, handlers + auth export. handlers 를 app/api/auth/[...nextauth]/route.ts 에서 Route Handler 로 wire.
어디서 auth() 부를지
| 위치 | Pattern |
|---|---|
| Server Component | const session = await auth(); |
| Server Action | same |
| Route Handler | same |
| Proxy | Export wrap: export const proxy = auth(req => { … }); |