Closed21
Auth.jsについて知りたい


- App Router-first (pages/ still supported)
らしい

もともとNext.jsのためのライブラリで、それが汎用化したんだもんね?

Universal auth()
A single method to authenticate anywhere
Use auth() instead of getServerSession, getSession, withAuth, getToken, and useSession (Read more)
ここが一番気になるかな...

シンプルになってて良いね。
authをfetcher内部に隠蔽したくなると思うんだけど、そうなるとSCとCCでデータ取得方法が異なるの難しいか?

fetcher内部で隠蔽して単にTanstackとか使えば良いのか

一旦手を動かすカー

headerのアイコンからsignOutしようとした
Error: `headers` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context

Server Actions として書いてなかったからっぽい
"use server";
import { signOut } from "@/auth";
export const logOutAction = async () => {
await signOut();
};
別のエラーになった
Error: Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported.

import { signOut } from "next-auth/react"
だった...

Userの拡張
このスクラップは2024/10/10にクローズされました