Gathering detailed insights and metrics for @react-native-community/cookies
Gathering detailed insights and metrics for @react-native-community/cookies
Gathering detailed insights and metrics for @react-native-community/cookies
Gathering detailed insights and metrics for @react-native-community/cookies
npm install @react-native-community/cookies
Typescript
Module System
Node Version
NPM Version
Java (47.79%)
Objective-C (43.84%)
JavaScript (6.07%)
Ruby (2.3%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
508 Stars
116 Commits
101 Forks
5 Watchers
9 Branches
25 Contributors
Updated on Jul 10, 2025
Latest Version
5.0.1
Package Id
@react-native-community/cookies@5.0.1
Unpacked Size
119.86 kB
Size
66.68 kB
File Count
17
NPM Version
6.14.6
Node Version
10.22.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
Cookie Manager for React Native
This module was ported from joeferraro/react-native-cookies. This would not exist without the work of the original author, Joe Ferraro.
@react-native-community/cookies
.✅ iOS
✅ Android
❌ Expo is working on their own cookie support (https://github.com/expo/expo/issues/6756)
Currently lacking support for Windows, macOS, and web. Support for these platforms will be created when there is a need for them. Starts with a posted issue.
yarn add @react-native-community/cookies
Then link the native iOS package
npx pod-install
react-native link @react-native-community/cookies
If automatic linking does not work, you can manually link this library by following the instructions below:
Libraries
and click Add Files to "Your Project Name"
Look under node_modules/@react-native-community/cookies/ios
and add RNCookieManagerIOS.xcodeproj
.libRNCookieManagerIOS.a
to `Build Phases -> Link Binary With Libraries.Run react-native link
to link the cookies library.
Or if you have trouble, make the following additions to the given files manually:
android/settings.gradle
1include ':@react-native-community_cookies' 2project(':@react-native-community_cookies').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/cookies/android')
android/app/build.gradle
1dependencies { 2 ... 3 implementation project(':@react-native-community_cookies') 4}
MainApplication.java
On top, where imports are:
1import com.reactnativecommunity.cookies.CookieManagerPackage;
Add the CookieManagerPackage
class to your list of exported packages.
1@Override 2protected List<ReactPackage> getPackages() { 3 return Arrays.asList( 4 new MainReactPackage(), 5 new CookieManagerPackage() 6 ); 7}
A cookie object can have one of the following fields:
1export interface Cookie { 2 name: string; 3 value: string; 4 path?: string; 5 domain?: string; 6 version?: string; 7 expires?: string; 8 secure?: boolean; 9 httpOnly?: boolean; 10} 11 12export interface Cookies { 13 [key: string]: Cookie; 14}
1import CookieManager from '@react-native-community/cookies'; 2 3// set a cookie 4CookieManager.set('http://example.com', { 5 name: 'myCookie', 6 value: 'myValue', 7 domain: 'some domain', 8 path: '/', 9 version: '1', 10 expires: '2015-05-30T12:30:00.00-05:00' 11}).then((done) => { 12 console.log('CookieManager.set =>', done); 13}); 14 15*NB:* When no `domain` is specified, url host will be used instead. 16*NB:* When no `path` is specified, an empty path `/` will be assumed. 17 18// Set cookies from a response header 19// This allows you to put the full string provided by a server's Set-Cookie 20// response header directly into the cookie store. 21CookieManager.setFromResponse( 22 'http://example.com', 23 'user_session=abcdefg; path=/; expires=Thu, 1 Jan 2030 00:00:00 -0000; secure; HttpOnly') 24 .then((success) => { 25 console.log('CookieManager.setFromResponse =>', success); 26 }); 27 28// Get cookies for a url 29CookieManager.get('http://example.com') 30 .then((cookies) => { 31 console.log('CookieManager.get =>', cookies); 32 }); 33 34// list cookies (IOS ONLY) 35CookieManager.getAll() 36 .then((cookies) => { 37 console.log('CookieManager.getAll =>', cookies); 38 }); 39 40// clear cookies 41CookieManager.clearAll() 42 .then((success) => { 43 console.log('CookieManager.clearAll =>', success); 44 }); 45 46// clear a specific cookie by its name (IOS ONLY) 47CookieManager.clearByName('http://example.com', 'cookie_name') 48 .then((success) => { 49 console.log('CookieManager.clearByName =>', success); 50 }); 51 52// flush cookies (ANDROID ONLY) 53CookieManager.flush() 54 .then((success) => { 55 console.log('CookieManager.flush =>', success); 56 });
React Native comes with a WebView component, which uses UIWebView on iOS. Introduced in iOS 8 Apple implemented the WebKit-Support with all the performance boost.
Prior to WebKit-Support, cookies would have been stored in NSHTTPCookieStorage
and sharedCookiesEnabled must be set on webviews to ensure access to them.
With WebKit-Support, cookies are stored in a separate webview store WKHTTPCookieStore
and not necessarily shared with other http requests. Caveat is that this store is available upon mounting the component but not necessarily prior so any attempts to set a cookie too early may result in a false positive.
To use WebKit-Support, you should be able to simply make advantage of the react-native-webview as is OR alternatively use the webview component like react-native-wkwebview.
To use this CookieManager with WebKit-Support we extended the interface with the attribute useWebKit
(a boolean value, default: FALSE
) for the following methods:
Method | WebKit-Support | Method-Signature |
---|---|---|
getAll | Yes | CookieManager.getAll(useWebKit:boolean) |
clearAll | Yes | CookieManager.clearAll(useWebKit:boolean) |
clearByName | Yes | CookieManager.clearByName(url:string, name: string, useWebKit:boolean) |
get | Yes | CookieManager.get(url:string, useWebKit:boolean) |
set | Yes | CookieManager.set(url:string, cookie:object, useWebKit:boolean) |
1import CookieManager from '@react-native-community/cookies'; 2 3const useWebKit = true; 4 5// list cookies (IOS ONLY) 6CookieManager.getAll(useWebKit) 7 .then((cookies) => { 8 console.log('CookieManager.getAll from webkit-view =>', cookies); 9 }); 10 11// clear cookies 12CookieManager.clearAll(useWebKit) 13 .then((succcess) => { 14 console.log('CookieManager.clearAll from webkit-view =>', succcess); 15 }); 16 17// clear cookies with name (IOS ONLY) 18CookieManager.clearByName('http://example.com', 'cookie name', useWebKit) 19 .then((succcess) => { 20 console.log('CookieManager.clearByName from webkit-view =>', succcess); 21 }); 22 23// Get cookies as a request header string 24CookieManager.get('http://example.com', useWebKit) 25 .then((cookies) => { 26 console.log('CookieManager.get from webkit-view =>', cookies); 27 }); 28 29// set a cookie 30const newCookie: = { 31 name: 'myCookie', 32 value: 'myValue', 33 domain: 'some domain', 34 path: '/', 35 version: '1', 36 expires: '2015-05-30T12:30:00.00-05:00' 37}; 38 39CookieManager.set('http://example.com', newCookie, useWebKit) 40 .then((res) => { 41 console.log('CookieManager.set from webkit-view =>', res); 42 });
No vulnerabilities found.
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 9/21 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
40 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More