Invalid export field 'query' encountered while attempting to deploy NextJS13 and Sanity.io on Vercel

Currently, I am diving into the world of NextJS13 and following a blog tutorial by Sonny Sangha called 'Let’s build a BLOG with Next.js 13 (Sanity v3, TypeScript, Tailwind CSS, Auth, CMS, Preview Mode)'. After completing the tutorial, my goal is to deploy the site on Vercel. However, I've encountered an issue:

app/(user)/page.tsx "query is not valid Page export Field

The problematic code snippet for that particular page is shown below:

import { groq } from "next-sanity";
import { client } from "../../sanity/lib/client"
import BlogList from "../../components/BlogList";

export const query = groq`
  *[_type == 'post'] {
    ...,
    author->,
    categories[]->,
  } | order(_createdAt desc)
`;

export default async function HomePage() {

  const posts = await client.fetch(query);
  return (
    <BlogList posts = {posts} />
  );
}

I attempted using getstaticprops but it seems like that approach is outdated in nextjs13. I am uncertain about other methods to query sanity.io without exporting the query (this is my first time working with nextjs). Any guidance or assistance on this matter would be highly appreciated.

Answer №1

To export only the React Component HomePage, you can simply remove the export keyword from query.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Node Webkit: No visible content?

Recently, I decided to explore Node-Webkit and encountered an issue. Despite coding the script below, nothing seems to appear on the screen and the file I intended to create remains missing. Even after installing npm for fs and os modules, I still face no ...

Distinguishing Between Angular and Ajax When Making Requests to a NodeJS Server

Trying to establish communication between an Angular client and a NodeJS server. Previous method using JQuery $.ajax({ url: "/list", type: "POST", contentType: "application/json", dataType: "json", success: function(data) { console.log("Data ...

How can I update my Node.js version on Ubuntu?

Having trouble installing node version 4.7 on Ubuntu. Everytime I try to upgrade, it shows that node 4.2.6 is already the newest version. I really need to install npm, but it requires node 4.7 or higher. ...

Resolving Timeout Error When Implementing Sequelize Include and Attributes

I keep encountering a timeout error whenever I attempt to utilize attributes from my include model. I am unsure if this issue is related to the way I am trying to include the attribute or if it is an unrelated problem within my code snippet. Below is the ...

Modify the bootstrap form dynamically in response to the user's input. Update the form layout instantly as the user types, with no need for clicking any buttons

Imagine a scenario where, as soon as you enter your credit card number, the form automatically undergoes a change without requiring a button click, similar to how a credit card logo pops up. The form detects changes instantly after the input field has be ...

The command npm start is failing to launch any React application

I recently set up a new react app using the `create-react-app` command, but when I tried running `npm start`, nothing happened and there were no errors in the console. Here are the troubleshooting steps I have taken so far: I attempted to remove the no ...

Encountering timeout issues while testing promises in supertest-as-promised with mocha

As I work on testing a function example, here is what I have: function generateJwt(){ var deferred = Q.defer(); deferred.resolve({ message: 'user created', token: signedJwt, userId: user.userId } ...

I dialed the network once, only to find it entangled in a tangle during the test

Below is the snippet of my testing code: context('event page', () => { before(() => { cy.visit('/event'); }); it('create banner', () => { cy.intercept('GET', '/events') ...

Operating two socket servers on a single port

I currently have a setup with three servers: Main server - responsible for listening to all HTTP requests Socket Server 1 : Listens to X types of socket requests Socket Server 2 : Listens to Y types of socket requests The goal is to run all three server ...

One way to incorporate type annotations into your onChange and onClick functions in TypeScript when working with React is by specifying the expected

Recently, I created a component type Properties = { label: string, autoFocus: boolean, onClick: (e: React.ClickEvent<HTMLInputElement>) => void, onChange: (e: React.ChangeEvent<HTMLInputElement>) => void } const InputField = ({ h ...

What is the initial function invoked when a directory is treated as callable?

In the open source blogging project Ghost, there is an index.js file which contains the following code: // # Ghost bootloader // Orchestrates the loading of Ghost // When run from command line. var ghost = require('./core'); ghost(); By runni ...

Guide to Serving PDF Files with Node, Express, and EJS

I've hit a roadblock with what I thought was a simple task. My goal is to create a link that will open a PDF file in a new tab, rather than automatically downloading it. Just to clarify, I already have the PDF file ready and saved. Here's a snip ...

Patterns for RESTful routes

I have set up the routes 'customers/45' and 'customers/recently-created' in my express application, but for some reason the 'customers/recently-created' route is not calling 'CustomerHandler.getRecentlyCreatedCustomers&ap ...

Creating an object with an array of objects as a field in MongoDB: A step-by-step guide

I have a unique schema here: const UniqueExerciseSchema = new Schema({ exerciseTitle: { type: String }, logSet: [{ weight: { type: Number }, sets: { type: Number }, reps: { type: Number }, }], }); After obtaining the da ...

Struggling with running my React App as I'm encountering some errors

Check out the code on Github: https://github.com/bhatvikrant/IndecisionApp I have already run npm i and then executed yarn run dev-server, utilizing webpack. My operating system is MacOs. I have also created the .babelrc file. The issue I encountered aft ...

React Native is unable to locate node and npm

https://i.stack.imgur.com/0jd8e.png Currently working on developing a fresh react-native application, encountering a particular error. Confirmed that Node and npm are both properly installed, with the PATH set accordingly. ...

Error: Required package bootstrap-duallistbox@github:istvan-ujjmeszaros/bootstrap-duallistbox is not found

After running npm install to install packages, I encountered the following error : npm ERR! code ELOCKVERIFY npm ERR! Errors were found in your package-lock.json, run npm install to fix them. npm ERR! Missing: bootstrap-duallistbox@github:istvan-ujj ...

Ways to resolve the npm error "peer dependency missing"

While reviewing the list of npm packages installed with npm list --depth 0 I came across two errors after the npm packages. Can anyone explain why these errors are occurring and how to resolve them? npm ERR! peer dep missing: chartist@^0.10.1, required ...

Can we include an option to display all pages in one row on a single page?

Is it possible to include an option to display all rows alongside the current options of 10, 15, and 100? I've been unable to locate this feature in the documentation: Check out the Codesandbox example: https://codesandbox.io/s/muidatatables-custom-t ...

Build a Docker container for a project that requires utilizing yarn link for dependencies

While working on my NextJS project, I made the decision to utilize yarn as my package manager and utilized yarn link for import aliases/absolute imports. This feature of yarn is quite handy and is recommended for managing aliases within a project. However, ...