Revalidate with Prisma
Answered
Catla posted this in #help-forum
CatlaOP
Lets say I have a static page with prisma, how can I revalidate the data, same as fetch
fetch('https://...', { next: { revalidate: 3600 } })export default async function Page() {
const categories = await prisma.category.findMany();
const statuses = await prisma.status.findMany();
return (...19 Replies
@Catla Lets say I have a static page with prisma, how can I revalidate the data, same as fetch `fetch('https://...', { next: { revalidate: 3600 } })`
export default async function Page() {
const categories = await prisma.category.findMany();
const statuses = await prisma.status.findMany();
return (...
you could do it with
unstable_cacheCatlaOP
I saw that, I tried to add
export const revalidate =1 but it didn't updated the data after a minute.@Catla I saw that, I tried to add `export const revalidate =1` but it didn't updated the data after a minute.
have you refreshed the page?
you should be able to get updated data in next visit
CatlaOP
So how can I update data that was fetched on the server?
without refresh
do you mean real time update?
CatlaOP
yes
via a Route Handler?
well it will need to use websocket with it
Answer
or you could use swr or react-query to fetch the data with a timer
CatlaOP
So swr or react-query + Route Handler right?
CatlaOP
Thank you