Common Next.js errorsDo not know how to serialize a BigInt
TypeError: Do not know how to serialize a BigInt means a BigInt reached JSON.stringify, which includes Response.json() and NextResponse.json() in your API routes. JSON has no BigInt type, so it throws.
Why it happens in production
Database drivers often return counts and 64-bit ids as BigInt (Postgres count(*), bigint columns, Prisma's BigInt fields). Everything else works until the value reaches an API response.
How to fix it
Convert where the data comes in // Counts fit easily in a normal number.
return { signups: Number(row.signups) };
// Ids that may be bigger than 2^53: send them as text.
return { id: row.id.toString() };
Converting once, where you read from the database, keeps every page and API route safe.