next.jssanity

Server Error Error: Configuration must contain projectId‘


I followed this tutorial: https://youtu.be/mx1dbMzd3tU

When i try to connect sanity and next i get this error

Server Error Error: Configuration must contain projectId‘


Solution

  • This error comes up when you're missing the projectId. You have to use projectId when creating your Sanity client instance:

    const client = sanityClient({
      projectId: 'yourproject-id',
      dataset: 'your dataset',
      token: 'Sanity build token',
      apiVersion: 'v1',
      useCdn: false // `false` if you want to ensure fresh data
    })