---
title: refresh
description: API Reference for the refresh function.
url: "https://nextjs.org/docs/app/api-reference/functions/refresh"
docs_index: /docs/llms.txt
lastUpdated: 2026-11-18
prerequisites:
  - "API Reference: /docs/app/api-reference"
  - "Functions: /docs/app/api-reference/functions"
related:
  - /docs/app/guides/server-actions
---

> For an index of all documentation, see [/docs/llms.txt](/docs/llms.txt).

`refresh` reruns dynamic work for the current route from a [Server Action](/docs/app/guides/server-actions) without invalidating server-side cached data.

## Usage

`refresh` can **only** be called from Server Actions. Use [`router.refresh()`](/docs/app/api-reference/functions/use-router#userouter) in Client Components. It cannot be used in Route Handlers or other contexts.

## Client cache behavior

Calling `refresh` clears the pages kept for back/forward navigation, but it does not invalidate other prefetched routes. A route prefetched before the Server Action can be reused until its stale time expires.

If a mutation changes cached data used by other routes, call [`updateTag`](/docs/app/api-reference/functions/updateTag) or [`revalidatePath`](/docs/app/api-reference/functions/revalidatePath) from the Server Action. These functions invalidate server-side cached data and currently clear prefetched routes from the client cache.

## Parameters

```tsx
refresh(): void;
```

## Returns

`refresh` does not return a value.

## Examples

**TypeScript**

```ts title="app/actions.ts" 
'use server'

import { refresh } from 'next/cache'

export async function createPost(formData: FormData) {
  const title = formData.get('title')
  const content = formData.get('content')

  // Create the post in your database
  const post = await db.post.create({
    data: { title, content },
  })

  refresh()
}
```

**JavaScript**

```js title="app/actions.js" 
'use server'

import { refresh } from 'next/cache'

export async function createPost(formData) {
  const title = formData.get('title')
  const content = formData.get('content')

  // Create the post in your database
  const post = await db.post.create({
    data: { title, content },
  })

  refresh()
}
```

### Error when used outside Server Actions

```ts title="app/api/posts/route.ts" 
import { refresh } from 'next/cache'

export async function POST() {
  // This will throw an error
  refresh()
}
```

- [Server Actions](/docs/app/guides/server-actions): How Server Actions work in Next.js, including the single-roundtrip response model, sequential dispatch, security, and caching integration.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/docs/llms.txt](/docs/llms.txt)