Server actions were unstable with Next.js 13 so I decided to continue to use the pages directory and now with the release of Next.js 14, it seems like the correct time to make the switch..
So I'm working through the official tutorial for Next.js 14 located here https://nextjs.org/learn which has been more or less pretty straightforward so far.
I am on chapter 12 and for context-related purposes, so far I have created and seeded a Vercel-hosted PostgreSQL DB, and then after that, I set up various server actions for receiving user and invoice data using SQL queries. These server actions are used by a few different components and after some thorough analysis using the network tab in the browser developers tools with some manual navigating: everything looks like it worked as it should.
Following this, the tutorial moves into mutating data, specifically user invoices by using server actions and I noticed that after using server actions to insert multiple invoices, the server components that I’m receiving from the server possess stale data!
At first, I thought that the server action responses for fetching the queries may have been cached so I implemented the noStore() function as recommended by the tutorial for my server actions. This should in theory force the server components to always run the server actions but the components were still loading steal data. I decided to do more investigating via the process of elimination and I next decided to stop and rerun my local project using “ctrl-c” -> “npm run dev”: the server components were still serving stale data. This is contrary to what next.js 14 + the tutorial advertises, so I decided to try deleting the generated “.next” folder and then restarting the local development, surely this would lead to some answers but no the data was still stale in the server components. This more or less told me that the issue had to be happening in the browser itself rather than next.js.
.