Next.js Discord

Discord Forum

does unstable_noStore only make a difference in production?

Answered
Gray-tailed Tattler posted this in #help-forum
Open in Discord
Gray-tailed TattlerOP
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
Answered by Ray
yes on dev mode, every page is dynamic
View full answer

11 Replies

Answer
Gray-tailed TattlerOP
@Ray is it the same when running npm run start?
@Gray-tailed Tattler <@743561772069421169> is it the same when running `npm run start`?
npm run start is starting the production build
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
Gray-tailed TattlerOP
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
yes because next will generate the page at build time by default
Gray-tailed TattlerOP
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.