Next.js Discord

Discord Forum

Data not updating?

Unanswered
Orinoco Crocodile posted this in #help-forum
Open in Discord
Orinoco CrocodileOP
I'm trying to fetch data server side, and then update that data when the client visits the page. But for some reason despite the data changing in backend and me rebuilding it, it's still showing the old data

export default async function Page() {
  const members = await getMembers();

  return <Team data={members} />;
}

19 Replies

Orinoco CrocodileOP
yarn run v1.22.19
$ next build
  ▲ Next.js 14.2.3

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
 ✓ Generating static pages (8/8)
 ✓ Collecting build traces
 ✓ Finalizing page optimization

Route (app)                              Size     First Load JS
┌ ○ /                                    563 B          92.8 kB
├ ○ /_not-found                          140 B          87.3 kB
├ ○ /icon.png                            0 B                0 B
├ ○ /opengraph-image.png                 0 B                0 B
├ ○ /team                                6.83 kB         106 kB
└ ○ /twitter-image.png                   0 B                0 B
+ First Load JS shared by all            87.1 kB
  ├ chunks/23-1adbec6eb53a8555.js        31.6 kB
  ├ chunks/fd9d1056-14e083ac9b0544be.js  53.7 kB
  └ other shared chunks (total)          1.9 kB


○  (Static)  prerendered as static content
Orinoco CrocodileOP
which is good?
try adding this to your root layout.tsx (app/layout.tsx)

export const dynamic = "force-dynamic"
Orinoco CrocodileOP
Its exported as a static site so I dont think that will work
@Orinoco Crocodile which is good?
but you want to ypdate the data so it has to be dynamic
Orinoco CrocodileOP
Error: Page with `dynamic = "force-dynamic"` couldn't be exported. `output: "export"` requires all pages be renderable statically because there is not runtime server to dynamic render routes in this output format. Learn more: https://nextjs.org/docs/app/building-your-application/deploying/static-exports
Orinoco CrocodileOP
wanted to fetch server side then update client side so theres little flickering but I guess not possible then
Orinoco CrocodileOP
If I use cache no-store it doesnt statically render the route at all causing navigation to not work as its a static site
I guess will just have to fetch only on client
@Orinoco Crocodile If I use cache no-store it doesnt statically render the route at all causing navigation to not work as its a static site
Turkish Van
Yes and no, it doesn't statically render the route because You chose it to be like that.

Since You're opting out of cache, it is server-rendered on demand.

I might be wrong, but If You really want the rest of Your page to be statically pre-rendered, the only way would be to fetch Your data on the client.

Unless You want to use an experimental Partial Prerendering feature.
Orinoco CrocodileOP
gotcha thanks