Next.js Discord

Discord Forum

Approuter mimicking getStaticProps?

Answered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hi I'm using next 14 app router

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?

4 Replies

because the page is static generated by default
Answer
@Ray because the page is static generated by default
Masai LionOP
ohhh
wasnt aware of that
thanks Ray