Files
gil-wiki/reference/4.api/3.utils/refresh-cookie.md
gil 5f664546cf feat: 위키 저장소 초기 커밋
- CLAUDE.md 운영 규칙
- wiki/ 정리된 지식 페이지 (Nuxt + Claude Code)
- raw/ 원본 자료
- reference/ Nuxt 4.x 공식 문서

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 00:31:51 +09:00

1.2 KiB

title, description, links
title description links
refreshCookie Refresh useCookie values manually when a cookie has changed
label icon to size
Source i-simple-icons-github https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/cookie.ts xs

::important This utility is available since Nuxt v3.10. ::

Purpose

The refreshCookie function is designed to refresh cookie value returned by useCookie.

This is useful for updating the useCookie ref when we know the new cookie value has been set in the browser.

Usage

<script setup lang="ts">
const tokenCookie = useCookie('token')

const login = async (username, password) => {
  const token = await $fetch('/api/token', { /** ... */ }) // Sets `token` cookie on response
  refreshCookie('token')
}

const loggedIn = computed(() => !!tokenCookie.value)
</script>

::note{to="/docs/4.x/guide/going-further/experimental-features#cookiestore"} Since Nuxt v3.12.0, the experimental cookieStore option is enabled by default. It automatically refreshes the useCookie value when cookies change in the browser. ::

Type

export function refreshCookie (name: string): void