
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis error happens because Next.js can't serialize undefined values when passing props from getServerSideProps to your component. Next.js uses JSON to transfer data from server to client, and undefined isn't valid JSON.
In your case, the .artists field is coming back as undefined from your Sanity query, likely because:
artists field setartists with the correct field nameundefined valuesHow to fix it:
Option 1 - Use nullish coalescing in your return statement:
return {
props: {
...exhibition,
artists: exhibition.artists || null
}
}Option 2 - Spread the entire query response (cleaner approach):
return {
props: { ...exhibition }
}Option 3 - Filter out undefined values:
const cleanProps = Object.fromEntries(
Object.entries(exhibition).filter(([_, v]) => v !== undefined)
);
return {
props: cleanProps
}Also check your GROQ query - Make sure there are no syntax errors. Common issues include:
fieldName-> for references)If you share your full query, I can help spot any syntax issues. The GROQ documentation is also helpful for validating query syntax.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store