Clarification NextJS Caching Revalidation

Hi! i have the function:
const getData = unstable_cache(
async () => {
const usersData = await db.select().from(users);
return { users: usersData };
},
["users"],
{
revalidate: false
},
);

export default async function Page() {
const data = await getData();

return (
<main className="container mx-auto p-4">
<h1 className="mb-6 text-3xl font-bold">User and Course Management</h1>
<CreateCoursePopup />
<UsersTable users={data.users} />
</main>
);
}
const getData = unstable_cache(
async () => {
const usersData = await db.select().from(users);
return { users: usersData };
},
["users"],
{
revalidate: false
},
);

export default async function Page() {
const data = await getData();

return (
<main className="container mx-auto p-4">
<h1 className="mb-6 text-3xl font-bold">User and Course Management</h1>
<CreateCoursePopup />
<UsersTable users={data.users} />
</main>
);
}
and I have the update function:
"use server";

import { adminAction } from "@/server/api/actions";
import { updateUserInput } from "@/validators/users";
import { revalidatePath, revalidateTag } from "next/cache";
import { users } from "@/server/db/schema";
import { db } from "@/server/db";
import { eq } from "drizzle-orm";
import { z } from "zod";

export const updateUserAction = adminAction
.schema(updateUserInput)
.action(async ({ parsedInput }) => {
await db.update(users).set(parsedInput).where(eq(users.id, parsedInput.id));
revalidateTag("users");
});

export const deleteUserAction = adminAction
.schema(z.object({ id: z.string() }))
.action(async ({ parsedInput }) => {
await db.delete(users).where(eq(users.id, parsedInput.id));
revalidateTag("users");
});
"use server";

import { adminAction } from "@/server/api/actions";
import { updateUserInput } from "@/validators/users";
import { revalidatePath, revalidateTag } from "next/cache";
import { users } from "@/server/db/schema";
import { db } from "@/server/db";
import { eq } from "drizzle-orm";
import { z } from "zod";

export const updateUserAction = adminAction
.schema(updateUserInput)
.action(async ({ parsedInput }) => {
await db.update(users).set(parsedInput).where(eq(users.id, parsedInput.id));
revalidateTag("users");
});

export const deleteUserAction = adminAction
.schema(z.object({ id: z.string() }))
.action(async ({ parsedInput }) => {
await db.delete(users).where(eq(users.id, parsedInput.id));
revalidateTag("users");
});
and the data on the page is not revalidatnig when I call the functions, I've tried revalidatePath, same issue. I know the function works because when I Crtl + Shift + R the data is correct. Any insights into why?
1 Reply
Ani
AniOP3w ago
nextjs 15 and also the page is showing a static icon even tho the page is clearly dynamic what am i missing? i'm also router.refresh() ing and it doesn't work same on build and dev with and without turbopack
Want results from more Discord servers?
Add your server