@nuxt/docs-nightly 4.4.0-29533953.9698f387 → 4.4.0-29534143.9efac4dc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,6 +36,7 @@ export interface CookieOptions<T = any> extends Omit<CookieSerializeOptions & Co
36
36
  default?: () => T | Ref<T>
37
37
  watch?: boolean | 'shallow'
38
38
  readonly?: boolean
39
+ refresh?: boolean
39
40
  }
40
41
 
41
42
  export interface CookieRef<T> extends Ref<T> {}
@@ -60,6 +61,7 @@ Most of the options will be directly passed to the [cookie](https://github.com/j
60
61
  | `encode` | `(value: T) => string` | `JSON.stringify` + `encodeURIComponent` | Custom function to encode the cookie value. Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to encode a value into a string suited for a cookie's value. |
61
62
  | `default` | `() => T \| Ref<T>` | `undefined` | Function returning the default value if the cookie does not exist. The function can also return a `Ref`. |
62
63
  | `watch` | `boolean \| 'shallow'` | `true` | Whether to watch for changes and update the cookie. `true` for deep watch, `'shallow'` for shallow watch, i.e. data changes for only top level properties, `false` to disable. <br/> **Note:** Refresh `useCookie` values manually when a cookie has changed with [`refreshCookie`](/docs/4.x/api/utils/refresh-cookie). |
64
+ | `refresh` | `boolean` | `false` | If `true`, the cookie expiration will be refreshed on every explicit write (e.g. `cookie.value = cookie.value`), even if the value itself hasn’t changed. Note: the expiration is not refreshed automatically — you must assign to `.value` to trigger it. |
63
65
  | `readonly` | `boolean` | `false` | If `true`, disables writing to the cookie. |
64
66
  | `maxAge` | `number` | `undefined` | Max age in seconds for the cookie, i.e. the value for the [`Max-Age` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.2). The given number will be converted to an integer by rounding down. By default, no maximum age is set. |
65
67
  | `expires` | `Date` | `undefined` | Expiration date for the cookie. By default, no expiration is set. Most clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting a web browser application. <br/> **Note:** The [cookie storage model specification](https://datatracker.ietf.org/doc/html/rfc6265#section-5.3) states that if both `expires` and `maxAge` is set, then `maxAge` takes precedence, but not all clients may obey this, so if both are set, they should point to the same date and time! <br/>If neither of `expires` and `maxAge` is set, the cookie will be session-only and removed when the user closes their browser. |
@@ -163,6 +165,28 @@ function save () {
163
165
  </template>
164
166
  ```
165
167
 
168
+ ### Refreshing Cookies
169
+
170
+ ```vue
171
+ <script setup lang="ts">
172
+ const session = useCookie(
173
+ 'session', {
174
+ maxAge: 60 * 60, // 1 hour
175
+ refresh: true,
176
+ default: () => 'active',
177
+ })
178
+
179
+ // Even if the value does not change,
180
+ // the cookie expiration will be refreshed
181
+ // every time the setter is called
182
+ session.value = 'active'
183
+ </script>
184
+
185
+ <template>
186
+ <div>Session: {{ session }}</div>
187
+ </template>
188
+ ```
189
+
166
190
  ### Cookies in API Routes
167
191
 
168
192
  You can use `getCookie` and `setCookie` from [`h3`](https://github.com/h3js/h3) package to set cookies in server API routes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "4.4.0-29533953.9698f387",
3
+ "version": "4.4.0-29534143.9efac4dc",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",