ngx-cookie-service
Advanced tools
Comparing version 15.0.0 to 16.0.0-rc.0
import * as i0 from "@angular/core"; | ||
export declare type SameSite = 'Lax' | 'None' | 'Strict'; | ||
export type SameSite = 'Lax' | 'None' | 'Strict'; | ||
export interface CookieOptions { | ||
@@ -4,0 +4,0 @@ expires?: number | Date; |
{ | ||
"name": "ngx-cookie-service", | ||
"description": "Angular cookie service", | ||
"version": "15.0.0", | ||
"version": "16.0.0-rc.0", | ||
"license": "MIT", | ||
@@ -25,2 +25,3 @@ "author": "Stepan Suvorov <stevermeister@gmail.com>", | ||
"angular-15", | ||
"angular-16", | ||
"ivy", | ||
@@ -83,4 +84,4 @@ "ivy-compatible", | ||
"peerDependencies": { | ||
"@angular/common": "^15.0.0", | ||
"@angular/core": "^15.0.0" | ||
"@angular/common": "^16.0.0-rc.0", | ||
"@angular/core": "^16.0.0-rc.0" | ||
}, | ||
@@ -98,7 +99,3 @@ "dependencies": { | ||
}, | ||
"module": "fesm2015/ngx-cookie-service.mjs", | ||
"es2020": "fesm2020/ngx-cookie-service.mjs", | ||
"esm2020": "esm2020/ngx-cookie-service.mjs", | ||
"fesm2020": "fesm2020/ngx-cookie-service.mjs", | ||
"fesm2015": "fesm2015/ngx-cookie-service.mjs", | ||
"module": "fesm2022/ngx-cookie-service.mjs", | ||
"typings": "index.d.ts", | ||
@@ -111,7 +108,5 @@ "exports": { | ||
"types": "./index.d.ts", | ||
"esm2020": "./esm2020/ngx-cookie-service.mjs", | ||
"es2020": "./fesm2020/ngx-cookie-service.mjs", | ||
"es2015": "./fesm2015/ngx-cookie-service.mjs", | ||
"node": "./fesm2015/ngx-cookie-service.mjs", | ||
"default": "./fesm2020/ngx-cookie-service.mjs" | ||
"esm2022": "./esm2022/ngx-cookie-service.mjs", | ||
"esm": "./esm2022/ngx-cookie-service.mjs", | ||
"default": "./fesm2022/ngx-cookie-service.mjs" | ||
} | ||
@@ -118,0 +113,0 @@ }, |
@@ -16,6 +16,6 @@ # NGX Cookie Service | ||
Angular service to read, set and delete browser cookies. Originally based on the [ng2-cookies](https://www.npmjs.com/package/ng2-cookies) library. The experienced team behind [Studytube](https://www.studytube.nl/) will take care of our cookie service from now on. | ||
Angular service to read, set and delete browser cookies. Originally based on | ||
the [ng2-cookies](https://www.npmjs.com/package/ng2-cookies) library. The experienced team | ||
behind [Studytube](https://www.studytube.nl/) will take care of our cookie service from now on. | ||
> Note: `ViewEngine` support has been removed on 13.x.x. See [compatability matrix](https://github.com/stevermeister/ngx-cookie-service#supported-versions) for details | ||
## Installation | ||
@@ -32,6 +32,7 @@ | ||
## Usage | ||
Add the cookie service to your `app.module.ts` as a provider: | ||
```typescript | ||
import { CookieService } from 'ngx-cookie-service'; | ||
import {CookieService} from 'ngx-cookie-service'; | ||
@@ -62,3 +63,5 @@ @NgModule({ | ||
That's it! | ||
### Angular 14+ | ||
1. Angular 14 introduced support for standalone components. | ||
@@ -103,4 +106,7 @@ If you are using just standalone components, you can import the service directly into the component | ||
``` | ||
## Server Side Rendering | ||
Ngx Cookie Service supports Server Side Rendering (SSR) via dedicated library [ngx-cookie-service-ssr](https://www.npmjs.com/package/ngx-cookie-service-ssr). | ||
Ngx Cookie Service supports Server Side Rendering (SSR) via dedicated | ||
library [ngx-cookie-service-ssr](https://www.npmjs.com/package/ngx-cookie-service-ssr). | ||
Only install `ngx-cookie-service-ssr` library (and skip `ngx-cookie-service`) for SSR | ||
@@ -117,3 +123,4 @@ | ||
2. By default, browser cookies are not | ||
available in SSR because `document` object is not available. To overcome this, navigate to `server.ts` file in your SSR | ||
available in SSR because `document` object is not available. To overcome this, navigate to `server.ts` file in your | ||
SSR | ||
project, and replace the following code | ||
@@ -126,2 +133,3 @@ | ||
``` | ||
with this | ||
@@ -131,14 +139,15 @@ | ||
server.get('*', (req, res) => { | ||
res.render(indexHtml, { | ||
req, | ||
providers: [ | ||
{ provide: APP_BASE_HREF, useValue: req.baseUrl }, | ||
{ provide: 'REQUEST', useValue: req }, | ||
{ provide: 'RESPONSE', useValue: res }, | ||
], | ||
}); | ||
}); | ||
res.render(indexHtml, { | ||
req, | ||
providers: [ | ||
{provide: APP_BASE_HREF, useValue: req.baseUrl}, | ||
{provide: 'REQUEST', useValue: req}, | ||
{provide: 'RESPONSE', useValue: res}, | ||
], | ||
}); | ||
}); | ||
``` | ||
3. This will make sure the cookies are available in `REQUEST` object, and the `ngx-cookie-service-ssr` can use `REQUEST.cookies` to access the | ||
3. This will make sure the cookies are available in `REQUEST` object, and the `ngx-cookie-service-ssr` can | ||
use `REQUEST.cookies` to access the | ||
cookies in SSR. Then proceed to use `ngx-cookie-service` as usual. | ||
@@ -157,4 +166,7 @@ 4. See the [sample repo](https://github.com/pavankjadda/angular-ssr-docker) for more details. | ||
| Angular Version | Supported Version | | ||
| ---------------------- | ----------------- | | ||
| 13.x.x or later (Ivy) | 13.x.x or later | | ||
|------------------------|-------------------| | ||
| 16.x.x | 16.x.x | | ||
| 15.x.x | 15.x.x | | ||
| 14.x.x | 14.x.x | | ||
| 13.x.x | 13.x.x | | ||
| <=12.x.x (View Engine) | 12.0.3 | | ||
@@ -194,3 +206,3 @@ | ||
cookieService.set('test', 'Hello World'); | ||
cookieService.set('test', 'Hello World', { expires: 2, sameSite: 'Lax' }); | ||
cookieService.set('test', 'Hello World', {expires: 2, sameSite: 'Lax'}); | ||
``` | ||
@@ -299,2 +311,3 @@ | ||
- [Pavan Kumar Jadda](https://github.com/pavankjadda) | ||
- [paroe](https://github.com/paroe) | ||
@@ -311,3 +324,2 @@ - [CunningFatalist](https://github.com/CunningFatalist) | ||
- [Nikel163](https://github.com/Nikel163) | ||
- [pavankjadda](https://github.com/pavankjadda) | ||
@@ -314,0 +326,0 @@ # License |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318
68347
13
564
2
1