All Questions
304
questions
77
votes
1
answer
50k
views
Next.js: Reduce data fetching and share data between pages
I'm looking for solutions for better data fetching in a Next.js app. In this question I'm not just looking for a solution, I'm looking for multiple options so we can look at the pros and cons.
The ...
7
votes
2
answers
3k
views
Sanity and Nextjs: content is not updating until re-deploy
I am having an issue getting content from my production Sanity Studio onto my production blog. I am using Next.js v13 and Sanity v3. The site is deployed on Vercel.
When I post from both my local ...
5
votes
2
answers
5k
views
next.js13 fetching data with an async function and also use state?
i hope you are having a great day ! i got a question... i'm currently learning next.js 13 and so i thought doing a personal project with it would be a good idea . Currently i'm doing an e-commmerce ...
4
votes
1
answer
7k
views
Why NextJS give me this hydrating error after refreshing the page?
When I refresh my page I got these erorrs :
Text content does not match server-rendered HTML.
Hydration failed because the initial UI does not match what was rendered on the server.
There was an ...
4
votes
1
answer
1k
views
Next.js - How to use getStaticProps to fetch Menu data and then pass it to the layout?
I am using Sanity.io as a backend, within Sanity I am handling the data for my main menu (parent/children object arrays).
Whilst I can fetch this data just fine, I want to do so via getStaticProps, as ...
4
votes
3
answers
6k
views
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: https://github....
4
votes
0
answers
219
views
Getting fetch error when deploying Nextjs / TS app to Vercel
Im getting this error when I try to deploy an app using Nextjs / TS / Sanity to Vercel
18:39:44.458] Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/...
3
votes
3
answers
2k
views
Cannot using React Syntax Highlighter in Next.js 13 & Sanity v3
Hello i have a problem for my project using Sanity v3 and React Syntax Highlighter. When i use Refactor library for showing my code in the browser it works by looking a tutorial in Code Input by ...
3
votes
1
answer
1k
views
Next JS Rewrites for Sanity CMS giving 404 page after login
I'm currently hosting a Next JS site on Netlify with a Sanity CMS backend for content editing. I've got it configured to run on the single domain IE - examplesite.com has the front-end website, where ...
3
votes
3
answers
932
views
Data is not updated after changes in the Sanity Studio
I am quite new to Sanity v3 + Next.js v13. Everything works great on my test site, but I have a problem when I update a document (project) or add a new one in the Sanity Studio – these changes are not ...
3
votes
1
answer
590
views
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 ...
3
votes
1
answer
1k
views
Sanity Studio: conditionally hide fields based on value from a reference field
Is there a way to conditionally hide fields based on the value of a referenced field?
I have two types: Destination and DestinationType
Below is the reference from the Destination type to the ...
3
votes
0
answers
76
views
Server Error: Unknown block type "code", please specify a serializer for it in the `serializers.types` prop
I am building a blog website using Sanity and NextJS. and facing error like:
Server Error
Error: Unknown block type "code", please specify a serializer for it in the serializers.types prop
I'...
3
votes
3
answers
901
views
Problem Deploying a Next JS + Sanity Project to Vercel
I was on a project and used nextjs with sanity but after almost finishing my project, I just don't see any way to deploy it. Learning sanity took quite a bit of time but what meaning is there if I can'...
3
votes
2
answers
1k
views
Upstream dependency conflict, npm sanity/client
I'm trying to make a nextjs/sanity project at the moment, and I think I may have installed sanity client twice, but not entirely sure.
This is the error I'm getting in the command terminal:
npm ERR! ...
3
votes
1
answer
215
views
Error while connecting sanity content lake to frontend
I'm getting an error while fetching blogs from sanity to my template, I'm creating a next.js website
Error: Error: Unknown block type "undefined", please specify a
serializer for it in the ...
2
votes
2
answers
2k
views
Content is not updating until re-deploy nextjs 13 and sanity
Hello i am using nextjs 13 server components using /app directory and sanity studio. my code looks like this
const Page = async () => {
const query = groq`*[_type == "university"]`;
...
2
votes
2
answers
6k
views
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‘
2
votes
2
answers
4k
views
SVG is being passed to img src as an object
For a website using NextJS and Sanity.io,
I am importing an image locally
import large_logo from '../../assets/logo-large-1200x630.svg
and am calling it inside an img tag as src
<img src={...
2
votes
2
answers
1k
views
Sanity GROQ: How do i get drafts for the array of references in a document?
I have a document type page which contains an array of blocks that are the references to other object types. When i fetch the data for page document, it returns draft data for document but not for the ...
2
votes
1
answer
983
views
Live Preview mode Sanity on NextJS 13
I cant seem to check if preview mode is activated or not for my website.
I was following a YouTube tutorial but I think it might be outdated when I am using the new NextJS update.
This is what i was ...
2
votes
1
answer
641
views
previewData is not a function error after updating NextJS
I have a NextJS and Sanity.io blog project. Today I updated NextJS from 13.2.3 to 13.4.2 and when I try to run it, I get this error:
Error: (0 , next_headers__WEBPACK_IMPORTED_MODULE_1__.previewData) ...
2
votes
1
answer
745
views
Module '"sanity"' has no exported member 'defineConfig'
I've just finished working on a project using Next.js 13 and Sanity as a headless CMS. Here is the issue I'm experiencing:
When I run
vercel build
I get the error that 'sanity' has no exported member ...
2
votes
1
answer
635
views
Is it safe to edit the schema of a blog post in Sanity, after I already have added 4-5 long posts (using the same schema)?
I currently have a blog running on Next.js + Sanity. I have had a lot of success, but in the past when setting it all up encountered a scary error while editing the blog post schema, that basically ...
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
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
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
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
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
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
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
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
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
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 ...
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
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
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:...
1
vote
2
answers
2k
views
Could not resolve dependency with sanity in nextjs app
I am trying to deploy my next.js project, but I keep getting the following error with everything I do:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! ...
1
vote
2
answers
1k
views
How to set the fill of SVGs that are imported from CDN?
I'm developing a website using Next JS and I want to display some SVG icons that I stored using Sanity. How do I display the SVG that I get from the Sanity CDN if I want to be able to dynamically ...
1
vote
3
answers
2k
views
NextJs Google fonts issue - Only one font gets displayed
I'm connecting Google Fonts link to the HEAD section in _app.js file of my NextJs application. The link contains two fonts.
https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&family=...
1
vote
1
answer
101
views
algolia-sanity updating doesn't work nextjs
i am trying to automatically update my algolia index by using the sanity-algolia package and the sanity webhook (i am using the legacy webhook) but it doesn't work.
Here's my /api/route.js file
import ...