Next.js Discord

Discord Forum

Revalidate with Prisma

Answered
Catla posted this in #help-forum
Open in Discord
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 (...
Answered by Ray
well it will need to use websocket with it
View full answer

19 Replies

CatlaOP
I saw that, I tried to add export const revalidate =1 but it didn't updated the data after a minute.
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