
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI searched for specific video tutorials on using block-content-to-react with Gatsby, but unfortunately couldn't find dedicated video content on this exact topic. While "Learn With Jason" has done Sanity episodes, I wasn't able to locate a specific Gatsby + Portable Text video tutorial.
However, since you already have your data coming through Gatsby's GraphQL API, I can help guide you through the implementation!
block-content-to-reactThe block-content-to-react package you linked is now considered legacy. The modern, recommended approach is to use @portabletext/react instead, which offers better performance and more flexibility.
Since you're already getting data via Gatsby's GraphQL API, here's how to render it:
@portabletext/react (recommended):npm install @portabletext/reactThen in your Gatsby component:
import { PortableText } from '@portabletext/react'
function BlogPost({ data }) {
return (
<article>
<h1>{data.sanityPost.title}</h1>
<PortableText value={data.sanityPost._rawBody} />
</article>
)
}
export const query = graphql`
query($slug: String!) {
sanityPost(slug: { current: { eq: $slug } }) {
title
_rawBody
}
}
`Key point: Use _rawBody (or whatever your field name is with the _raw prefix) in your GraphQL query to get the raw Portable Text data structure that the renderer expects.
block-content-to-react:npm install @sanity/block-content-to-reactimport BlockContent from '@sanity/block-content-to-react'
function BlogPost({ data }) {
return (
<article>
<h1>{data.sanityPost.title}</h1>
<BlockContent
blocks={data.sanityPost._rawBody}
projectId="your-project-id"
dataset="your-dataset"
/>
</article>
)
}Both packages support custom serializers/components for rendering custom blocks, marks, and types:
const components = {
types: {
image: ({value}) => <img src={value.imageUrl} />,
},
marks: {
link: ({children, value}) => <a href={value.href}>{children}</a>,
},
}
<PortableText value={data._rawBody} components={components} />While I couldn't find the specific video you're looking for, these resources might help:
The core concepts are the same across React frameworks—you're rendering Portable Text blocks that come through as JSON from your GraphQL query. The main thing to remember is to use the _raw prefix in your Gatsby queries!
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