Module not found error: Can't resolve '@sanity/client' in Next.js project

5 repliesLast updated: Nov 29, 2025

Hey everyone, I'm new to all this and I'm sure I'm missing something simple but I'm running into the following on my next+sanity project:
Module not found: Can't resolve '@sanity/client'
> 1 | import sanityClient from '@sanity/client';`
I've been following this
tutorial on the sanity site (more or less)Any help or pointers would be greatly appreciated.
🙂
AI Update

I 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/client

or if you're using yarn:

yarn add @sanity/client
import 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:

If 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-sanity

This package includes @sanity/client and provides additional utilities specifically for Next.js projects. The Sanity + Next.js documentation has great examples of modern setups!

Show original thread
5 replies

Was this answer helpful?

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.

Related contributions