콘텐츠로 이동

Functions: refresh

Source URL: https://nextjs.org/docs/app/api-reference/functions/refresh

Copy page

마지막 업데이트 2026년 2월 20일

refresh서버 액션 내부에서 클라이언트 라우터를 새로 고칠 수 있게 해줍니다.

refresh오직 서버 액션 내부에서만 호출할 수 있습니다. 라우트 핸들러, 클라이언트 컴포넌트 또는 다른 어떤 컨텍스트에서도 사용할 수 없습니다.

refresh(): void;

refresh는 값을 반환하지 않습니다.

app/actions.ts

JavaScriptTypeScript

'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()
}

서버 액션 외부에서 사용하면 발생하는 오류

섹션 제목: “서버 액션 외부에서 사용하면 발생하는 오류”

app/api/posts/route.ts

JavaScriptTypeScript

import { refresh } from 'next/cache'
export async function POST() {
// This will throw an error
refresh()
}

supported.

Send