admin管理员组文章数量:1405614
I recently started learning NextJS and decided to create my first blog with posts.
The blog is fetching post data from Firebase's Firestore and displays posts on the homepage. There is also an admin page where you can send a new post to the database.
My problem is: when I create a new post in production and send it to the database, the new post doesn't show up until I push something to production again.
I think I need to set up revalidation (for example every 60 sec for testing, once a week on production), but I’m not able to figure it out.
Could someone please help me with this? I use NextJS version 15.1.7
async function getArticles() {
const collectionReference = collection(db, "posts");
const collectionSnapshot = await getDocs(collectionReference);
return collectionSnapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
}));
}
export default async function PostsList(){
const articles = await getArticles(); // Načítání článků
const sortedArticles = articles.sort((a, b) => new Date(b.date) - new Date(a.date));
return (
...
)
}
I tried add this line of code:
export const revalidate = 60;
which didn't work
I think I have to use this advice, but I don't know how to apply that in my code: nextjs documentation
本文标签: firebaseHow to revalidate Firestore data in NextJS server componentStack Overflow
版权声明:本文标题:firebase - How to revalidate Firestore data in NextJS server component? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744293925a2599250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论