Questions tagged [sanity]

Sanity is a structured content platform and API that also offers an open source, React-based Studio that functions as like a headless CMS on top of the Sanity APIs.

Sanity treats content as structured data and makes it easily available over an API. The collaborative editor, called the Content Studio, is a fully customizable, client-side web application. Documentation here.

833 questions
5
votes
3 answers

Error: No "sanity.json" file found in plugin "@sanity/base"

I am new to sanity and trying to follow along to a tutorial on youtube but I am getting this error when I run ' sanity start'. Can anyone give me advice on what I should do? sanity error
Saalim
  • 61
  • 2
5
votes
2 answers

Resolve reference in Block Content in Sanity.io

I have the Content Block in Sanity like so: export default { title: "Block Content", name: "blockContent", type: "array", of: [ /// stuff here { title: "Book", type: "reference", to: [{ type: "book" }], …
5
votes
1 answer

"sanity init" command fails at "Resolving dependencies"

I just wanted to create a new Sanity project. After running npm install -g @sanity/cli, which worked fine, I run sanity init. At the last step it crashed with the following warning: Error Message From CMD I didn't find any similar issues yet, so I…
wallzry
  • 115
  • 9
5
votes
1 answer

How to set value through patch event to any field from custom input in sanity.io?

I want to make patch event from custom component and set a value to another field in document, but couldn’t find documentation about patch events. there are only example without field specification: PatchEvent.from(set(value)) Does anybody knows…
4
votes
1 answer

WARN The default export of @sanity/client has been deprecated. Use the named export `createClient` instead

I'm currently learning React-Native. I try to use sanity in my project. This is my sanity.js page. I could not get why sanityClient is strike-through. I also get this error " WARN The default export of @sanity/client has been deprecated. Use the…
4
votes
3 answers

Sanity.io and Image from next/image issue

This is my first official post on Stack so bear with me; I am currently using Nextjs with Sanity as my headless CMS and I'm encountering what seems to be a TypeScript type issue. GH:…
4
votes
4 answers

Module not found: Can't resolve '@sanity/client' > 1 | import sanityClient from '@sanity/client';

I am using "npm install -g @sanity/cli sanity init --coupon javascriptmastery2022" everything is workig well until I want to fetch the data from sanity client it says: ***Module not found: Can't resolve '@sanity/client' 1 | import sanityClient from…
Mahdi Ehssani
  • 53
  • 1
  • 5
4
votes
4 answers

Uncaught Error: Configuration must contain `projectId`( when using environment variable )

Only when using an environment variable for projectId inside sanityClient, it can't find it even though is inside the .env file My goal is to connect backend data from Sanity to my frontend in reactjs. expected to see the content published in…
4
votes
2 answers

Querying images from Sanity for GatsbyImage

I'm having trouble sourcing images from Sanity using the new gatsby-plugin-image. The documentation says to do the following: import React from 'react' import {getGatsbyImageData} from 'gatsby-source-sanity' import {GatsbyImage} from…
4
votes
1 answer

Sanity draft preview not working with block content

I've made two iterations of a blog creation experience. The first consisted of an array of different object and document types such as paragraph, gallery, quote, etc while the second, and most recent one, takes advantage of block content to…
Mr.Smithyyy
  • 2,157
  • 12
  • 49
  • 95
4
votes
1 answer

Ordering documents in Sanity

I have a set of documents and I want editors to be able to choose the order they appear. I haven't been able to find any information about this. Is there a standard or built-in way to handle this in Sanity, or a plugin? I could add a sortOrder field…
Jake
  • 12,713
  • 18
  • 66
  • 96
4
votes
3 answers

How to retrieve a referenced field data inside inputComponent in Sanity.io?

In Sanity Studio, I was trying to get all Document's properties inside an input Component. Follow this article An officially supported way to get at the document content I was able to use withDocument HOC to get Document data, but some of them have…
Hieu Pham
  • 349
  • 1
  • 3
  • 12
4
votes
5 answers

How to increment property per document in Sanity?

We are making a system where users can submit orders. Orders have an incrementing property deliveryNumber; a new order should get a deliveryNumber that is one higher than the previous order. Is there any built-in support for this in Sanity? If not,…
ArneHugo
  • 6,051
  • 1
  • 26
  • 47
4
votes
2 answers

How to create a default `creationDate` for a document in sanity.io?

I have checked the documentation of how to do this, but I have not found an answer. Basically, when a document is created/published, I want to set a createdDate for the document (as a read-only/hidden field).
JAM
  • 6,045
  • 1
  • 32
  • 48
3
votes
1 answer

How to custom preview mode in Sanity Studio with Nextjs

I have problem to show the preview mode because the url must contain few parameter that is "category" and "slug". (example in my picture bellow). This is the error url with undefined param So, i cant get the param for my URL This is my code //…
Toss
  • 63
  • 4
1
2
3
55 56