- CLAUDE.md 운영 규칙 - wiki/ 정리된 지식 페이지 (Nuxt + Claude Code) - raw/ 원본 자료 - reference/ Nuxt 4.x 공식 문서 Co-authored-by: Cursor <cursoragent@cursor.com>
1.2 KiB
1.2 KiB
title, description, links
| title | description | links | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| refreshCookie | Refresh useCookie values manually when a cookie has changed |
|
::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