This is the error:
Configuration must contain `projectId`
at initConfig (http://localhost:3001/static/js/bundle.js:65087:53)
at _SanityClient2.config (http://localhost:3001/static/js/bundle.js:65901:101)
at new _SanityClient2 (http://localhost:3001/static/js/bundle.js:65888:299)
at createClient (http://localhost:3001/static/js/bundle.js:66026:29)
at http://localhost:3001/static/js/bundle.js:66036:36
at ./src/components/sections/featured/featured.jsx (http://localhost:3001/static/js/bundle.js:1328:75)
at options.factory (http://localhost:3001/static/js/bundle.js:160931:31)
at __webpack_require__ (http://localhost:3001/static/js/bundle.js:160330:32)
at fn (http://localhost:3001/static/js/bundle.js:160589:21)
at ./src/pages/home/home.jsx (http://localhost:3001/static/js/bundle.js:2657:96)
This is my client.js
import sanityClient from "@sanity/client";
export default sanityClient({
projectId: 'twxbdh4g',
dataset: "production",
token: process.env.NEXT_PUBLIC_SANITY_TOKEN,
apiVersion: '2024-04-25',
useCdn: true,
})
I've looked everywhere but I can't find a solution, this error popped up when I added a new sanity content block.
CORS Origins are added and credentials allowed.
I took a quick look at the documentation.
You are using the default import: import sanityClient from "@sanity/client";
Which is marked as depreciated:
/**
createClient
instead of the default
export*/
So you should use import {createClient} from '@sanity/client'
;
Relevant docs: https://github.com/sanity-io/client?tab=readme-ov-file#the-default-export-is-replaced-with-the-named-export-createclient