
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can help you with this! Without seeing the exact error message from your screenshot, I'll address the most common issue that occurs after upgrading Sanity Studio and matches the symptoms you're describing.
The Most Likely Issue:
Your code is importing groq from next-sanity, which should still work in current versions. However, based on the SEO context mentioning "groq import" issues, you might be experiencing one of these scenarios:
defineQuery approachnext-sanity and Sanity Studio versionsThe Recommended Solution: Switch to defineQuery
The modern approach is to use defineQuery instead of groq. According to the defineQuery documentation, this provides better TypeScript support and enables automatic type generation. Here's how to update your sanity.utils.ts:
import { createClient, defineQuery } from "next-sanity"; // Change groq to defineQuery
import {apiVersion, dataset, projectId} from "./env"
import { Project } from "../types/Project";
import { client } from "./lib/client";
import { Page } from "../types/Page";
export async function getProjects(): Promise<Project[]> {
const client = createClient({
projectId,
dataset,
apiVersion,
})
return client.fetch(
defineQuery(`*[_type == 'project']{
_id,
_createdAt,
name,
"slug": slug.current,
"image": image.asset->url,
}`)
)
}
export async function getProject(slug: string): Promise<Project> {
const client = createClient({
projectId,
dataset,
apiVersion,
})
return client.fetch(
defineQuery(`*[_type == 'project' && slug.current == $slug][0]{
_id,
_createdAt,
name,
"slug": slug.current,
"images": images[].asset->url,
}`),
{slug}
)
}
// Apply the same pattern to getPages() and getPage()Alternative: Remove the Wrapper Entirely
If you don't need type generation, you can simply remove the groq wrapper and use plain template strings:
return client.fetch(
`*[_type == 'project']{
_id,
_createdAt,
name,
"slug": slug.current,
"image": image.asset->url,
}`
)The groq template tag was primarily for syntax highlighting and doesn't modify the query string, so removing it won't affect functionality.
Additional Steps:
Update next-sanity: Make sure your next-sanity package is also up to date:
npm install next-sanity@latestCheck package versions: Ensure there's no version mismatch between your Sanity packages:
npm list sanity next-sanity @sanity/clientClear cache: Sometimes clearing your Next.js cache helps:
rm -rf .next
npm run devWhy defineQuery is Better:
Using defineQuery gives you:
If you're still seeing the error after trying these solutions, please share the exact error message from your screenshot so we can provide more specific guidance!
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