revalidatePath
Discards the cached page at a path, so the next request renders it again.
Discards the cached page at a path, so the next request renders it again. Call it from a server function or a loader after a change. Pages are matched by their app path (without the mount base).
Import#
ts
import { revalidatePath } from "@shadow-js/dusk/server";
Signature#
ts
async function revalidatePath(path: string): Promise<void>
Parameters#
| Name | Description |
|---|---|
path |
App path, for example "/posts/7". |
Returns#
A promise that resolves when the entries are removed. A handler without isr() has no cached page: the call
resolves and does nothing.
Throws#
- DuskError
SERVER_NO_REQUEST_EVENToutside a request.
Examples#
ts
export const savePost = serverFn({}, async (input) => { await db.save(input); await revalidatePath(`/posts/${input.id}`); });