#fetchquery static rendering

1 messages · Page 1 of 1 (latest)

long flowerBOT
#

Hi @fierce bramble. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The knowledge sources do not explicitly mention a way to use fetchQuery while maintaining static rendering in Next.js.

In fact, the documentation states that related functions like preloadQuery specifically use a cache: 'no-store' policy, which prevents Server Components from being eligible for static rendering [Next.js Server Rendering].

While fetchQuery is the standard way to load Convex data in Server Components, Server Actions, and Route Handlers, it is typically used for dynamic data fetching [Next.js Server Rendering; Module: nextjs].

If you are using a pure server-side architecture without client components, the standard pattern provided is:

import { fetchQuery } from "convex/nextjs";  
import { api } from "@/convex/_generated/api";  
  
export default async function PureServerPage() {  
  // This call currently triggers dynamic rendering
  const tasks = await fetchQuery(api.tasks.list, { list: "default" });  
  
  return (
    <div>
      {tasks.map(task => <p key={task._id}>{task.text}</p>)}
    </div>
  );
}

[Server Actions and Route Handlers]

There is no information in the provided documents regarding how to override the default dynamic behavior of fetchQuery to support Next.js static generation (SSG) or Incremental Static Regeneration (ISR) with manual revalidation.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: