PortableText content prop error in Next.js after publishing to Sanity
Looking at your code, I can see the issue! You're using the old deprecated @sanity/block-content-to-react package API with serializers and content props, but it looks like you've upgraded to the newer @portabletext/react package which has a different API.
The @sanity/block-content-to-react package was deprecated in favor of @portabletext/react, and the new package uses different prop names:
contentโvalueserializersโcomponents- You no longer need
datasetandprojectIdprops
Here's how to update your code:
import { PortableText } from '@portabletext/react'
<PortableText
className='mt-10'
value={post.body} // Changed from 'content' to 'value'
components={{ // Changed from 'serializers' to 'components'
block: {
h1: ({children}) => (
<h1 className='text-2xl font-bold my-5'>{children}</h1>
),
h2: ({children}) => (
<h2 className='text-xl font-bold my-5'>{children}</h2>
),
},
list: {
bullet: ({children}) => <ul className='ml-4'>{children}</ul>,
},
listItem: {
bullet: ({children}) => <li className='list-disc'>{children}</li>,
},
marks: {
link: ({value, children}) => (
<a className='text-blue-500 hover:underline' href={value?.href}>
{children}
</a>
),
},
}}
/>Key changes to note:
- Props structure: The components receive
childreninstead of being passed the entire props object - Organization: Components are organized into
block,list,listItem, andmarkscategories - Links: Links are now under
marks.linkand receive avalueprop with the link data
Make sure you have @portabletext/react installed:
npm install @portabletext/reactYou can find more details in the official Sanity documentation on presenting Portable Text, which covers the migration from the old package to the new one.
Show original thread13 replies
Sanity โ Build the way you think, not the way your CMS thinks
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.