
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see you're getting a "Module not found: Can't resolve '@sanity/client'" error. This is a common issue that's easy to fix!
The problem is that you haven't installed the @sanity/client package in your Next.js project. When following older tutorials, the import syntax has changed slightly, but the main issue here is the missing dependency.
Here's how to fix it:
npm install @sanity/clientor if you're using yarn:
yarn add @sanity/clientimport sanityClient from '@sanity/client';Use this:
import { createClient } from '@sanity/client';
export const client = createClient({
projectId: 'your-project-id',
dataset: 'production',
apiVersion: '2023-06-10', // use current date (YYYY-MM-DD format)
useCdn: true,
});A few important notes:
'your-project-id' with your actual Sanity project ID (you can find this in your Sanity management dashboard)apiVersion should be set to today's date or the date you're developing (format: YYYY-MM-DD)createClient function is now the standard way to initialize the clientIf you're using the newer Sanity setup, you might also want to consider using the next-sanity package instead, which provides better integration with Next.js. You can install it with:
npm install next-sanityThis package includes @sanity/client and provides additional utilities specifically for Next.js projects. The Sanity + Next.js documentation has great examples of modern setups!
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