#does unstable_noStore only make a difference in production?

13 messages · Page 1 of 1 (latest)

dusky kite
#

does unstable_noStore only make a difference in production? I'm doing this tut https://nextjs.org/learn/dashboard-app/static-and-dynamic-rendering and if i comment out noStore() in

export async function fetchRevenue() {
  // Add noStore() here prevent the response from being cached.
  // This is equivalent to in fetch(..., {cache: 'no-store'}).
  // noStore()

  try {
    // Artificially delay a response for demo purposes.
    // Don't do this in production :)

    console.log('Fetching revenue data...');
    await new Promise((resolve) => setTimeout(resolve, 3000));

    const data = await sql<Revenue>`SELECT * FROM revenue`

    console.log('Data fetch completed after 3 seconds.');

    return data.rows
  } catch (error) {
    console.error('Database Error:', error)
    throw new Error('Failed to fetch revenue data.')
  }
}

I see no difference on page load

Understand how rendering works in Next.js, and make your dashboard app dynamic.

verbal wingBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

dusky kite
agile marsh
dusky kite
#

@agile marsh is it the same when running npm run start?

agile marsh
#

if you comment out noStore on fetchLatestInvoices , fetchCardData and fetchRevenue, the dashboard page will be static generated

#

and when data change, it will not get updated

#

you can npm run build and see the page is builded as prerendered as static content

dusky kite
#

ahh okay I see now. After commenting out noStore() everywhere, building and then viewing the build with npm run start the components load instantly despite having the setTimeout

agile marsh
#

yes because next will generate the page at build time by default

dusky kite
#

oh right bah. i think my mind gets crossed up with next when talking about caching methods and rendering strategies.

#

it'll sink in eventually, partially why i'm doing this /learn/ tutorial.