Approuter mimicking getStaticProps?
Answered
Masai Lion posted this in #help-forum
Masai LionOP
Hi I'm using next 14 app router
I created a fetchProducts function to fetch data from firebase
Then I call
Now the issue I'm experiencing now is, after I update the database, it doesn't reflect in the production deploy till I redeploy the page. what's happening?
I created a fetchProducts function to fetch data from firebase
// /app/function/fetchProd.ts
"use server";
import { adminDb } from "@/firebaseAdmin";
import { TrendingType } from "../Components/Home";
export async function fetchProducts() {
const snapshot = await adminDb(...)
const documents: TrendingType[] = [];
snapshot.forEach(...);
return JSON.parse(JSON.stringify(documents));
}Then I call
fetchProducts in my page.tsx this way and then pass the results as a prop to HomeComp// /app/page.tsx
import HomeComp from "./Components/Home";
import { fetchProducts } from "./function/fetchProd";
export default async function Home() {
const prod = await fetchProducts();
return (
<>
<HomeComp products={prod} />
</>
);
}Now the issue I'm experiencing now is, after I update the database, it doesn't reflect in the production deploy till I redeploy the page. what's happening?
Answered by Ray
https://nextjs.org/docs/app/api-reference/functions/unstable_noStore
add this to your fetchProducts function
add this to your fetchProducts function
4 Replies
because the page is static generated by default
https://nextjs.org/docs/app/api-reference/functions/unstable_noStore
add this to your fetchProducts function
add this to your fetchProducts function
Answer
@Ray because the page is static generated by default
Masai LionOP
ohhh
wasnt aware of that
wasnt aware of that
thanks Ray