All Questions
Tagged with sanity typescript
55
questions
11
votes
10
answers
16k
views
Sanity.io [vite] Internal server error: [postcss] Cannot read properties of undefined (reading 'config') error
Spinning up the sanity studio gets me this error. The page spins up just fine in local host. Any help fixing this would be greatly appreciated
here is the error in full:
[plugin:vite:css] [postcss] ...
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
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 ...
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
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
2
answers
2k
views
How do I fix a 'Missing enviornment variable' in Sanity?
I have tried everything to fix it but still getting the error
Uncaught error: Missing environment variable: NEXT_PUBLIC_SANITY_DATASET
http://localhost:3333/static/sanity-5377bc10.js:4605:43956
Error:...
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
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
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
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 ...
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
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
1
answer
81
views
Sanity npm package throws type error on build
As the title says, I use next-sanity for my Next.js blog. I recently wanted to update all npm packages. Now I can´t run npm run build as the one of the dependncies itself throws a type error as ...
1
vote
2
answers
235
views
sanity groq not returning queried data
Im having trouble using groq to fetch data. All my other groq queries work expect this one. The data im trying to query works with the sainty groq vs plugin when i manually set the $slug variable but ...
1
vote
2
answers
524
views
Unknown block type "youtube". Problem with serialization React Portable Text
I added custom block YouTube block using this tutorial. I have problem with render the YouTube embed in a frontend.
[slug].tsx file:
import { GetStaticProps } from 'next';
import Header from '../../...
1
vote
1
answer
420
views
How can I filter slug data
I'm using sanity to get slug data and I just wan't to show related posts from the same post category.
I tried to fetch all data and pass it to the state. but I have no idea how to get current posts ...
1
vote
0
answers
530
views
PortableText Typescript Error with Sanity.Io in Nextjs Application
I am upgrading my NextJs/Sanity application to NextJS 13 using Sanity.io and typescript.
The PortableText tag no longer works. The value and components attributes are flagged as an error in Visual ...
1
vote
1
answer
249
views
Using custom list preview with prepare in sanity schema fails production build
I am fairly new with next.js, typescript and sanity, and so far everything was going fine. I have multiple schemas defined in my project and it runs fine in development. linting checks do not return ...
1
vote
1
answer
53
views
I'm working on an e-commerce project with typescript and sanity.io, and i am getting an error
Uncaught TypeError: Cannot read properties of undefined (reading '_ref').
when trying to use the code to display the content of the API on the webpage. what seems to be the issue and how can I come to ...
1
vote
1
answer
955
views
Sanity.io reusable schema field types
I'm new to Sanity.io. I'm just wondering if there is a way that I can optimize my codes and reuse the fields in different schemas.
Im thinking something like this:
cars.ts:
export default {
name: '...
1
vote
1
answer
442
views
ClientError: Unable to parse value of "$tweetId=undefined". Please quote string values
I am using sanity, also if you need more information I will provide it as soon as possible.
When I go to http://localhost:3000/api/getComments it writes me that error:
ClientError: Unable to parse ...
1
vote
0
answers
481
views
Why does injecting the sanity client in a nestjs service provider result in a "TypeError: client_1.default is not a function"?
Creating a service provider in nestjs and importing a sanity client:
import { Injectable } from '@nestjs/common';
import sanityClient, { SanityClient } from '@sanity/client';
@Injectable()
export ...
1
vote
0
answers
654
views
Loading SVG images in Gatsby from Sanity
What is the right approach to load SVG images from a Sanity CMS in a Gatsby (v3) website? The Sanity documentation states that
GIF and SVG pass through the image pipeline untouched, but if you want ...
0
votes
1
answer
3k
views
getStaticPaths was added without a getStaticProps - typescript
I am creating a blog using nextJS, typescript and sanity CMS. I have created the homepage where the post shows perfectly. next I am fetching the blog post details when I click the post with their ...
0
votes
1
answer
771
views
Missing "key" prop for element in iterator in next,js typescript [duplicate]
This is my portfolio web app, i have made different components but when i am trying 'npm run build' it gives the following error : Missing "key" prop for element in iterator, can anyone ...
0
votes
1
answer
66
views
Display concatenation of object schema field in Sanity Studio instead of last item
I'm quite new to Sanity and I'd like to know how to do this.
I'm adding items using the following schema
defineField({
title: 'Ingredients',
name: 'ingredients',
type: 'array',
of: [
...
0
votes
1
answer
762
views
How can I fetch data from Sanity
I tried to create a schema and fetch data from sanity. but console log shows undefined. what am I doing wrong here? I probably failed at creating the schema but I'm not sure.
Testimonials.tsx
...
0
votes
2
answers
264
views
I can't add any classes to my next.js 13 component which is rendering sanity data within a portableText element
I am trying to add styles to my elements. I've tried every method I can find online, including creating a custom component and passing it to the PortableText element, adding the component directly to ...
0
votes
1
answer
277
views
How can I pass multiple data with GetServerSideProps
I'm trying to pass multiple sanity data into a component. but I can only use getserversideprops one time. how can I use more than one sanity data?
pages > members.tsx
export const ...
0
votes
0
answers
14
views
Sanity - How do you prevent edits of custom studio component text?
Context
I'm trying to customize the style of a custom quote annotation in Sanity Studio using a custom annotation component, showing one of the annotation's properties inside of it (the author of the ...
0
votes
0
answers
82
views
Next.js revalidation on slug page don't work
i'm using Next.js and Sanity as CMS. I have an author page [slug].tsx and i'm trying to revalidate this page by using an api like revalidate.ts.
The author page index can revalidate informations like ...
0
votes
0
answers
59
views
Sanity Studio not taking projectId
sanity.config.ts
import { defineConfig } from 'sanity';
import { deskTool } from 'sanity/desk';
import { presentationTool } from 'sanity/presentation';
import { visionTool } from '@sanity/vision';
...
0
votes
1
answer
82
views
Next.js + Sanity.io debugging: "async/await is not yet supported in Client Components, only Server Components."
Beginner here building a website/e-commerce store using React, Next 14, Typescript, and Sanity for the CMS. I was following this tutorial here: https://www.youtube.com/watch?v=g2sE034SGjw&t
I'm ...
0
votes
0
answers
288
views
Sanity Rich text editor block options are showing up but are disabled and unable to use them
I'm currently working on a Next.js + Sanity Project. I'm having an issue with the type Block from Sanity. In a previous project it worked but in the current project (with the same setup), the block ...
0
votes
2
answers
375
views
React TypeScript: Resolving Type Error with Props
I've been working on a Next.js project with TypeScript for a portfolio website. Inside my Home functional component, I'm trying to initialize the state using the useState hook and setting initial ...
0
votes
1
answer
117
views
How do I make my sanity studio update to reflect on my nextjs app?
After setting up my sanity studio with the initial data it worked, but whenever i make a change and publish it, it still shows me my previous data in my next app. I even had to delete some data in the ...
0
votes
0
answers
138
views
Tailwindcss interfering with Sanity's PortableText/react
I'm working on a project that uses Sanity CMS rich text, and PortableText that parses through the text so it renders with proper formatting (ie. bullet points, bolded text, etc).
Wanting to learn ...
0
votes
1
answer
25
views
Typescript - How to extract values from Sanity API Result - JSON
I am trying to get the values from a Sanity Client API call and can't figure out how to get the values from resulting JSON.
Here is the result of the api call:
[
{
slug: { current: "test-...
0
votes
1
answer
20
views
What's the type of returned props in Next.js/TypeScript
Currently tyring to practice Next.js and running into some very rookie issues, would love some clarification, to get that 'ahaa' moment.
I'm using Next.js and learning Sanity, trying to fetch data (...
0
votes
0
answers
158
views
How to read data efficiently from sanity's useSanityQuery
I am building an e-commerce site using sanity from product data storage(CMS) with NuxtJS 3 as the web framework. To fetch data I am using the useSanityQuery hook provided by the @sanity/nuxt package. ...
0
votes
1
answer
1k
views
NEXT JS 13 infinite loop on use State, Error on Params, and error on hook definition
I am trying to create a shopping cart with NEXT JS and I am facing different errors in my code. first thing first I have created a route [product]/[productitems] in my apps folder. in my page.tsx file ...
0
votes
0
answers
99
views
How do I render a blog post as an array instead of an object in a Nextjs/Sanity Studio Blog?
This is my error:
Error: Objects are not valid as a React child (found: object with keys {_id, categories, title, _updatedAt, author, _createdAt, _rev, slug, _type}). If you meant to render a ...
0
votes
0
answers
78
views
Having issue fetching comment from sanity.io across all pages in Next Js
I have collections of comments from sanity.io, am trying to fetch the comments to make them available on all pages. I tried fetching it in the _app.tsx using getServerProps but am receiving undefined. ...
0
votes
0
answers
403
views
Issue with Sanity Next.js Live preview mode
I am trying to implement live preview mode for the blogs on my Next.js website. I followed all the steps mentioned in the Sanity docs (https://www.sanity.io/guides/nextjs-live-preview) and to ...
0
votes
0
answers
28
views
Sanity and Next.JS - My frontend don't read my sanityProject
https://github.com/EzequielMadrid/pro-portfolio
I try to read the sanity, and I'd like to show all the data that I'm calling, and in my frontend, the socials aren't seen. Socials're my first call.
0
votes
2
answers
437
views
Typescript props JSX.Element is not assignable to type ComponentType
I have a problem with type checking on renderDefault properties for my function object. url, string works as string but renderDefault keeps complaining. Created a type PreviewProps to assign the ...
0
votes
1
answer
829
views
Error: Unable to resolve image URL from source (undefined) | Next js typescript with sanity backend
I checked my source code and everything. looks okay! But problem comes only when working with Next Js Image tag. So creating schemas with sanity, then building the client and url Builder, importing ...
0
votes
1
answer
127
views
NextJS _app.tsx issue -error - ./pages/_app.tsx:3:12
Currently i'm having an issue while creating some custom script on my NextJs Project.
here's error Log;
error - ./pages/_app.tsx:3:12
Syntax error: Unexpected token, expected "from"
1 | ...