Refetching?
Hello I just put up an app using Next 13 app directory and I decided to give Drizzle a try. Everything went great but my data (fetched in a RSC and passed into a client component) is stale. I added new rows to the db, but Drizzle does not refetch. I searched docs and couldn't find an answer. What's the best way to go about refetching periodically?
7 Replies
caching issue? https://nextjs.org/docs/app/building-your-application/data-fetching/fetching#static-data-fetching
Data Fetching: Fetching
Learn how to fetch data in your Next.js application.
i have a feeling it's not a drizzle issue
I'm doing it like it says in drizzle ORM
This is how I'm seeing everyone else use it:
https://github.com/vercel/examples/blob/688af297729c2d817eb30151804fab0565fefe72/storage/postgres-kysely/components/table.tsx#L4
for example
has nothing to do with drizzle, you need to configure your route using route segment configs: https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
for example, if you want to always run a query per request and never cache the page you would add
export const revalidate = 0;
which ensures the page is always dynamically renderedFile Conventions: Route Segment Config
Learn about how to configure options for Next.js route segments.
Thank you Maston, I hadn't known about this. It seems I have a lot more reading to do.
.ts
I faced this similar problem too. I though it's drizzle but it was next.js
export const revalidate = 0;
export const dynamic = "force-dynamic";