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.
811
questions
2
votes
1
answer
84
views
Next Js Api routes response helpers (redirect)
I'M trying to create a login functionality in Next js.
Everything is pretty much done but I'm unable to redirect to homepage after login.
I'm using Next js with sanity as headless CMS
This is my login ...
2
votes
1
answer
274
views
How to use the Sanity Studio with a Custom backend?
We have a legacy app and would like to migrate to Sanity for the new editorial content, but want to keep the previous backend intact with the ability to edit it in Sanity. Curious if it is possible. ...
2
votes
2
answers
5k
views
What's the proper way for returning a response using Formidable on Nextjs Api?
I'm sending an uploaded file to a Next.js API route using FormData. The file is then processed on the API route using formidable and passed to sanity client in order to upload the asset, but I can't ...
2
votes
2
answers
10k
views
Refreshing Server side props - Nextjs
I have a list of posts, fetched with getServerSideProps in the home page, then these posts are passed as props to a Posts component, which maps those posts and pass each one to a Post component. ...
2
votes
1
answer
683
views
Missing 'fixed' and 'fluid' fields on image asset with `gatsby-source-sanity`
I'm trying to source images from Sanity with gatsby-source-sanity and gatsby-image. In the past I've had no issue querying the fluid image asset like so:
export const query = graphql`
query {
...
2
votes
1
answer
82
views
Dynamic pages at load time, not build time
I'm building an editorial site that regularly adds new content. As such, they've requested that articles and article content is loaded in at load time rather than having to run a build and wait for it....
2
votes
1
answer
6k
views
How to Async/Await using useEffect for fetching data? [duplicate]
I have looked up some questions but didn't manage to fix this issue. I am trying to add async and await to my useEffect where I am fetching for data.
Also, how can I add a simple loading text before ...
2
votes
1
answer
857
views
Is it possible to query document schema metadata in Sanity/GROQ?
I have a simple singleton document schema defined in my Sanity/NextJS project, to model my "Colophon" page (richText is a custom block field type):
export default {
title: 'Colophon',
...
2
votes
1
answer
423
views
...GatsbySanityImageFluid - Cannot read property 'fluid' of null
I'm working with Sanity and Gatsby
I'm trying to map over an array of images to display them in an image gallery. My GraphQL query is working, I am able to display a single image but I receive the ...
2
votes
2
answers
2k
views
How do I access an asset's URL when linked via reference in Sanity Studio?
I want to upload PDFs in Sanity Studio, then link to those PDFs in the main site content.
I've added a reference to a document which has a 'file' field in it to my simpleBlockContent input in Sanity ...
2
votes
1
answer
335
views
Is it possible to do geospatial queries in sanity.io?
I found out that sanity supports Geopoint type, but I could not find any information if it's possible to do any filter operation on this type. Are geospatial queries possible?
2
votes
1
answer
459
views
Storing Sanity token as a secret with Now doesn't work
I am trying to store a Sanity token as a secret when deploying my project with Now, but it all doesn't seem to work. Here is my situation:
I added my Sanity token as a secret to the CLI (I called it ...
2
votes
1
answer
69
views
How can I import a custom Portable text editor into my schema files
Trying to build on text editor and share it among all the schemas that need it in Sanity but cannot figure out how this is done.
I did look through the docs but they just build it to show in the view, ...
2
votes
1
answer
715
views
Nextjs 13 'use client' components rendering on server anyway with sanity
I'm trying to setup simple Nextjs application with Sanity studio, where Sanity is appended to my Next application, and lives under the route like /admin.
The problem is that when I try to access my ...
2
votes
0
answers
667
views
Next.js 13 'TypeError: fetch failed' while trying to render static pages using getStaticProps. Need help fixing code
I'm new to APIs. I'm using Sanity for my backend.
This is the error I get in the terminal:
- info Linting and checking validity of types
- info Creating an optimized production build
- info Compiled ...
2
votes
0
answers
295
views
Sanity - How to populate a list of predefined strings based on another field in the same document?
I want to make a section field which it's options will be based on the category value
I tried this but it didn't work
defineField({
name: 'category',
type: 'string',
title: 'Category'...
2
votes
0
answers
439
views
How to implement nested list using @portabletext/react npm in nextjs with sanity.io
i get stuck when wanna implement nested list using @portabletext/react package in nextjs, i need to show my list (in this case using bullet list) in different condition. In the normal condition to be ...
2
votes
0
answers
320
views
POST request to Sanity CMS using Next.js API & next-connect resulting in 500 ERROR
I am having trouble making a POST request of user info on a register form to the Sanity CMS.I am using Next.js & next-connect. I am getting a 500 error when making the request.
Here is a snippet ...
2
votes
1
answer
1k
views
Next.js page working on localhost but not on vercel
I'm building the blog for a website, and I just completed the search results page. When I tried it on localhost, it worked perfectly but when I deployed it to vercel it doesn't work at all. The ...
2
votes
0
answers
338
views
How do I add more than one item in orderable document list in sanity
I added 2 schema - 'abouts' and 'works'. In the Sanity dashboard, it is only showing the 'works' document list since I added it in the structure plugin...
import {defineConfig, isDev} from 'sanity'
...
2
votes
0
answers
403
views
Next.js 13 with sanity studio unexpected behaviour with layouts
I am trying to make a bloglike application using next.js 13 and sanity for the CMS.
I have created a navbar that I would like to only show on the standard page but not on the stanity studio page. The ...
2
votes
0
answers
307
views
Uncaught TypeError: Method Promise.prototype.then called on incompatible receiver #<Promise> at Proxy.then (<anonymous>)
Been trying to fix this for a while and it's becoming quite annoying, help would be really appreciated.
Context
using sanity.io cms and I think the error may come from client.js, where the client is ...
2
votes
2
answers
845
views
Vercel, Next.js, Sanity.io production deployment fails
I have a Next.js + Sanity.io project and when I deploy from local build using vercel CLI with
vercel build and then vercel deploy --prebuilt, it works great.
However, when I do vercel --prod to create ...
2
votes
0
answers
376
views
Object object being displayed when trying to render blockContent on React
I am working on a website and trying to render a blockContent from Sanity.io, in my React application, but it's displayed as only [object Object] on the website. I tried different queries on Sanity ...
2
votes
0
answers
455
views
Cannot read properties of undefined (reading 'length') Lottie React
I get an undefined issue while trying to set lotties using lottie-react
I am setting CDN link instead of just importing it directly .
This is the code :
{missions.map((mission : any) =>
(
<...
2
votes
1
answer
353
views
Uncaught TypeError: (0 , _sanity_client__WEBPACK_IMPORTED_MODULE_0__.sanityClient) is not a function
I'm trying to fetch data from Sanity into my react app for the first time. At the moment, I'm trying something small, so I have a schema called website_images, that has an image type called about and ...
2
votes
1
answer
748
views
Unknown type: code || getting this error in sanity as schema error
I Have installed sanity code-input plug-in using yarn. Now I'm having this error
Error
Here I'm using type code
{
name: 'exampleUsage',
title: 'Example usage',
type: 'code',
}...
2
votes
2
answers
2k
views
how to disable button until a request is completed
I have a like button and once a user clicks on it, the button should only allow one click (i.e allow only one like per user)
<button disabled={buttonState} onClick={() => {like(item)}}>
&...
2
votes
0
answers
330
views
Getting error while doing sanity start: Module not found: Error: Part "sanity:css-custom-properties" not implemented by any plugins
Error in ./node_modules/@sanity/base/lib/components/GlobalStyle.js
Module not found: Error: Part "sanity:css-custom-properties" not implemented by any plugins
@ ./node_modules/@sanity/base/...
2
votes
1
answer
398
views
Why does sanity cli get error while install it?
I'm trying:
npm install -g @sanity/cli
>> sanity init --coupon javascriptmastery2022
and I get this message:
sanity : File C:\Users\...\AppData\Roaming\npm\sanity.ps1 cannot be loaded. The
...
2
votes
2
answers
1k
views
How to set default value for radio button in Sanity Studio?
I'm trying to set the default value given a list of radio items in Sanity Studio.
Code:
export default {
name: 'banner',
title: 'Banner',
type: 'document',
fields: [
{
name: "...
2
votes
0
answers
411
views
fetch 'Object' type data from sanity CMS
I am working on a blog project built with nextJS, typescript. I have successfully been able to fetch data from sanity CMS. I am able to see the 'blog_title, author_name, description and etc'. The ...
2
votes
1
answer
921
views
I have problem with deploying Sanity studio on Netlify
it maybe silly questions to someone here but I have nowhere to ask so I came here.
I deployed my portfolio page with Sanity & Gatsby Starter.
It works okay → https://lovethis.one.
deploy status
...
2
votes
0
answers
550
views
Next-Auth v4.0 adapter for Sanity.io
I have tried to modify the existing adapter @ https://www.sanity.io/plugins/next-auth-sanity to be compatible with Next-Auth V4 to no avail.
As I have read that Next-Auth V4 introduces some breaking ...
2
votes
0
answers
2k
views
Error: Unable to resolve image URL from source (undefined) SANITY.IO
Error: Unable to resolve image URL from source (undefined)
I did my ImageBuilder configuration in another file and imported the urlFor function into my component. While I am able to map through/...
2
votes
1
answer
290
views
How to read/pass vercel system enviroment variables to code in Sanity?
I want to pass the VERCEL_GIT_COMMIT_REF variable to my javascript bundle. I've deployed Sanity in Vercel and it only passes variables with the prefix SANITY_STUDIO_.
So, I've created an environment ...
2
votes
0
answers
318
views
How to auto-populate referenced documents in a Sanity.io schema?
Here are the relationships I have:
Artists
Artworks -> references Artist from Artists
What I would like to do is view all the Artworks that reference a particular Artist inside the Artist Document ...
2
votes
0
answers
454
views
setPreviewData on Next.js /api serverless throws error (not a funciton)
I'm using next.js for presenting data from sanity.io and I'm deploying it as a serverless application on AWS (edge-optimized). At first this functionality was working but at some point it just stopped ...
2
votes
0
answers
490
views
Sanity CMS, referencing arrays within a document
My goal is to have a custom internalLink mark that is able to reference not just the post (which is easy enough since its a type: document) but also reference name: sections which returns array of ...
2
votes
4
answers
1k
views
I am building a React Application using the Sanity CMS for the backend but I am running into a client error when sending data to the backend
I am building a react application and using a Sanity CMS for the backend but I am running into an issue whenever I try to load data into the backend from the client.
Everything else works perfectly ...
1
vote
5
answers
7k
views
TypeError: (0 , next_sanity__WEBPACK_IMPORTED_MODULE_0__.createImageUrlBuilder) is not a function [closed]
I am trying to make nextjs typescript project using sanity.io but im not able to solve this problem. itis showing that createImageUrlBuilder is not a function.
enter image description here
here is my ...
1
vote
3
answers
2k
views
Error: Errors while building: ./node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js Module parse failed: Unexpected token (307:11)
Hi everyone hope you all doing good,
I am trying to add a plugin to sanity and the plugin is sanity-plugin-order-documents
.I have followed all the steps shown in the documentation step by step.
I ...
1
vote
3
answers
6k
views
Error: Unable to resolve image URL from source (null)
I am using Sanity and React to create a blog page. Everything seems to be okay but when you click on a blog to read more I get the error message "Error: Unable to resolve image URL from source (...
1
vote
5
answers
938
views
Sanity CMS data is not showing on the react app
I was following a tutorial on youtube (https://youtu.be/3HNyXCPDQ7Q) for creating a portfolio website. I hosted the website using Netlify, 20 days later when I revisited the website, the website was ...
1
vote
1
answer
4k
views
how to display images from (block content) rich text in portable text
how to display images from (block content) rich text in portable text using sanity as backend and next js as front end.
my portable text look like this
<PortableText
value={blog.body}
/>
no ...
1
vote
2
answers
453
views
Vercel Build Error: It looks like you're using options meant for '@sanity/preview-kit/client'
Hi Im having an odd issue with Vercel deployment because of sanity, this is the Vercel build error:
Error: It looks like you're using options meant for '@sanity/preview-kit/client', such as '...
1
vote
1
answer
3k
views
How to filter Sanity.io dataset based on a field on references
How to get all posts by a category slug in GROQ?
You can see that a post is added to one or more categories. I would like to get all posts by a category slug to show the posts on a category page. I am ...
1
vote
1
answer
2k
views
How to delete a document attribute in Sanity iO?
I have an array of objects in my Sanity Document called Images called Comments
an example comment object in comments[] array looks like :
{
"_key": "6510dc79cf8b",
&...
1
vote
1
answer
187
views
Operation times out with observable subscription
We have a subscription to an RxJS Observable that's obtained from the Sanity javascript client's listen method.
This works fine except that every now and then we get an error "The operation timed ...
1
vote
3
answers
1k
views
Access to an Array inside a Post Array with Sanity using next.js
I have an issue here trying to access a Post array that has inside a categories array. So if I console.log the data I see something like this:
{
posts: [
{
_createdAt: '2021-10-23T05:02:...