编译
编译通过就行楼主
Auth.js 5 signIn redirect:false 返回 { error, ok, status, url }。判断成功:!result.error && result.ok。注意 result.url 可能含 ?error= 参数,用 redirectTo 显式指定避免误判。
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。
toast 和 router.push 冲突,因为 toast 的状态更新会中断 router.push 的 startTransition。解决:用 window.location.href 硬导航,或先 toast 再 setTimeout(() => router.push, 0)。
遇到 hydration mismatch 报错,一般是服务端和客户端渲染的 HTML 不一致。常见原因:① 在组件中用了 Date.now() 或 Math.random() ② 用了 window/document 等浏览器 API ③ 服务端和客户端时区不同。解决:把动态值放到 useEffect 里设置,或加 suppressHydrationWarning。
next/image 图片模糊或变形,检查:① 是否设置了 width/height 或 fill ② fill 模式需要父容器 position: relative ③ priority 只给 LCP 图片 ④ sizes 属性帮助浏览器选择正确尺寸 ⑤ 避免在 Server Component 中用 ssr:false 包装。