奔跑
奔跑的树懒楼主
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子组件 Client 做交互。 Vercel Hobby 计划函数超时 10s,Pro 计划 60s,Enterprise 900s。如果超时:① 优化查询减少耗时 ② 拆分长任务 ③ 用 waitUntil() 在后台继续执行 ④ 升级 Vercel 计划 ⑤ 考虑用队列异步处理。 Vercel Edge Runtime 不支持 Prisma,因为 Prisma 依赖 Node.js 原生模块。Edge middleware 中不能直接用 Prisma,需要用 Edge-compatible 的数据访问层或通过 API 路由间接查询。 Server Action 提交后不跳转,可能是用了 router.push 而非 window.location.href。Next.js 15 + next-intl 的 router.push 在 startTransition 内会被 toast 的状态更新中断。解决:用 window.location.href 硬导航。 Prisma migrate 报 database does not exist,需要先创建数据库。用 npx prisma db push 或手动 createdb。如果是 Vercel Postgres 或 Supabase,确保 DATABASE_URL 指向正确的数据库实例。