Next.js Discord

Discord Forum

Question about Static Site Generation with Dynamic Data

Answered
Floh posted this in #help-forum
Open in Discord
Hi guys, I am trying to generate some static blog post pages using dynamic content from Supabase.

The pages say they were statically generated in my build log:
├ ● /[slug]                              
├   ├ /nikon-z8
├   └ /nikon-nikkor-z-400mm-f45-vr-s


But when I visit the page, the server is still making requests to Supabase (shown in screenshot).

My expectation was that the page content would be fetched and generated at build time, then the page would just sent to the browser without having to fetch the data (until revalidation).

Maybe I'm just not understanding something about SSG?
Is it just a matter of adjusting the caching behavior myself?
Answered by Floh
I was able to fix this with
export const dynamic = "force-static"
thought I don't fully understand how, i don't think i was doing anything that would cause dynamic rendering
View full answer

3 Replies

Additional evidence of data fetching in supabase for that request
The structure of my page component is essentially:

export async function generateStaticParams() {
  const items = // get list of reviews from database
  return items.map((item) => ({slug: item.slug})
}

const fetchReviewContent = async (slug: string) => {
  console.log("Fetching review", slug)
  const content = //get review content from supabase
  return content 
}

export default function Page({ params }: { params: {slug: string}}) {
  const {review} = await fetchReviewContent(params.slug)

  // render page
}
I was able to fix this with
export const dynamic = "force-static"
thought I don't fully understand how, i don't think i was doing anything that would cause dynamic rendering
Answer