Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.5k
feat(nuxt): addrefresh option to useCookie#33814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
riabinkovihor wants to merge7 commits intonuxt:mainChoose a base branch fromriabinkovihor:feat/cookie-refresh-option
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+79 −4
Open
Changes from1 commit
Commits
Show all changes
7 commits Select commitHold shift + click to select a range
f3df555 feat(nuxt): add `refresh` option to useCookie (#33811)
riabinkovihor4aaf723 feat(nuxt): change `refresh` option for httpOnly, add JSDoc comments …
riabinkovihor434e733 docs(nuxt): add useCookie `refresh` option description and example (#…
riabinkovihorf5085f7 Merge branch 'main' into feat/cookie-refresh-option
riabinkovihor77d0a54 feat(nuxt): move `nuxtApp` out of setter in cookieServerRef (#33811)
riabinkovihor1685e51 [autofix.ci] apply automated fixes
autofix-ci[bot]585c8e1 docs(nuxt): change use-cookie.md table align (#33811)
riabinkovihorFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Merge branch 'main' into feat/cookie-refresh-option
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitf5085f7f443d69c26432910cb567a24bb5e6b945
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -55,22 +55,22 @@ export function useCookie<T = string | null | undefined> ( | ||
| Most of the options will be directly passed to the [cookie](https://github.com/jshttp/cookie) package. | ||
| | Property| Type| Default| Description | | ||
| |---------------|------------------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| | `decode`| `(value: string) => T` | `decodeURIComponent` + [destr](https://github.com/unjs/destr). | Custom function to decode 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 decode a previously encoded cookie value into a JavaScript string or other object. <br/> **Note:** If an error is thrown from this function, the original, non-decoded cookie value will be returned as the cookie's value. | | ||
| | `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. | | ||
| | `default`| `() => T \| Ref<T>`| `undefined`| Function returning the default value if the cookie does not exist. The function can also return a `Ref`. | | ||
| | `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). | | ||
| | `refresh`| `boolean`| `false` | If `true`, the cookie expiration will be refreshed on every explicit write, even if the value itself hasn’t changed. | | ||
coderabbitai[bot] marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| | `readonly`| `boolean`| `false`| If `true`, disables writing to the cookie. | | ||
| | `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. | | ||
| | `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. | | ||
| | `httpOnly`| `boolean`| `false`| Sets the HttpOnly attribute. <br/> **Note:** Be careful when setting this to `true`, as compliant clients will not allow client-side JavaScript to see the cookie in `document.cookie`. | | ||
| | `secure`| `boolean`| `false`| Sets the [`Secure` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.5). <br/>**Note:** Be careful when setting this to `true`, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection. This can lead to hydration errors. | | ||
| | `partitioned` | `boolean`| `false`| Sets the [`Partitioned` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1). <br/>**Note:** This is an attribute that has not yet been fully standardized, and may change in the future. <br/>This also means many clients may ignore this attribute until they understand it.<br/>More information can be found in the [proposal](https://github.com/privacycg/CHIPS). | | ||
| | `domain`| `string`| `undefined`| Sets the [`Domain` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3). By default, no domain is set, and most clients will consider applying the cookie only to the current domain. | | ||
| | `path`| `string`| `'/'`| Sets the [`Path` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.4). By default, the path is considered the ["default path"](https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4). | | ||
| | `sameSite`| `boolean \| string`| `undefined`| Sets the [`SameSite` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7). <br/>- `true` will set the `SameSite` attribute to `Strict` for strict same-site enforcement.<br/>- `false` will not set the `SameSite` attribute.<br/>- `'lax'` will set the `SameSite` attribute to `Lax` for lax same-site enforcement.<br/>- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.<br/>- `'strict'` will set the `SameSite` attribute to `Strict` for strict same-site enforcement. | | ||
| ## Return Values | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
You are viewing a condensed version of this merge commit. You can view thefull changes here.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.