Registry / storage / react-native-nitro-cookies

react-native-nitro-cookies

JSON →
library1.1.0jsnpmunverified

A high-performance cookie manager for React Native built on Nitro Modules and JSI, achieving near-native speed. Version 1.1.0 provides ESM-first TypeScript APIs with full iOS and Android support. Key differentiators: synchronous cookie access via JSI, no async bridge overhead, and native WebView integration unlike react-native-cookies or react-native-webview-cookies.

npm install react-native-nitro-cookies
INSTALL
IMPORT
SIG · REACT-NATIVE-NITRO
R
react-native-nitro-cookies
storagejavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NitroCookies
import { NitroCookies } from 'react-native-nitro-cookies'
const NitroCookies = require('react-native-nitro-cookies')
ESM-only since v1.0.0; CommonJS require will fail with newer React Native versions
getCookies
import { getCookies } from 'react-native-nitro-cookies'
import { getCookies } from 'react-native-nitro-cookies/cookies'
All exports are from the main entry; subpath imports are not supported
Cookie
import type { Cookie } from 'react-native-nitro-cookies'
import { Cookie } from 'react-native-nitro-cookies'
Cookie is a type-only export; use import type to avoid runtime issues
setCookie
import { setCookie } from 'react-native-nitro-cookies'
import { setCookie } from 'react-native-nitro-cookies/setCookie'
All functions are exported directly; no subpath exports

Shows main cookie operations: get, set, and remove cookies using ESM TypeScript imports with async/await.

import { NitroCookies, getCookies, setCookie, removeCookie } from 'react-native-nitro-cookies'; async function manageCookies(domain: string) { // Get all cookies for a domain const cookies = await getCookies(domain); console.log('Current cookies:', cookies); // Set a cookie await setCookie({ domain, name: 'sessionId', value: 'abc123', path: '/', secure: true, httpOnly: true, }); // Remove a specific cookie await removeCookie(domain, 'sessionId'); }
Debug
Known issues
gotchagetCookies returns null for domains with no cookies; check for null before iterating.
fix
Use optional chaining: const cookies = (await getCookies(domain)) ?? [];
affects: >=1.0.0
breakingsetCookie now requires the domain field; previously it was optional and fell back to the top-level domain.
fix
Always pass an explicit domain in the cookie object.
affects: >=1.1.0
gotchaAll cookie functions are synchronous under the hood but return Promises for compatibility; don't force synchronous use via .value.
fix
Always use await or .then() to access the result.
affects: >=1.0.0
deprecatedThe cookie property 'expires' as a number is deprecated; use a string in date format.
fix
Replace expires with a date string like '2025-12-31T23:59:59Z'.
affects: >=1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'react-native-nitro-cookies'
Missing dependency or misconfigured metro resolver for Nitro Modules.
fix
Run 'npm install react-native-nitro-cookies' and ensure 'react-native-nitro-modules' is also installed.
TypeError: (0, _NitroCookies.getCookies) is not a function
Library not linked correctly or JSI initialization failed.
fix
Rebuild the app: 'npx react-native run-ios' or 'npx react-native run-android' with clean build.
Invariant Violation: NativeModule: NitroCookies is null
Nitro Modules native part not registered or React Native version incompatible.
fix
Check that react-native-nitro-modules >=0.35.0 is installed and linked. On Android, ensure MainApplication.java includes NitroModules init.
undefined is not an object (evaluating 'cookies.map')
getCookies returned null for empty cookie jar.
fix
Use (await getCookies(domain)) ?? [] to provide default empty array.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
react-nativerequiredCore peer dependency for React Native runtime
react-native-nitro-modulesrequiredRequired for Nitro module system; version >=0.35.0 <1.0.0
Agent activity
26 hits · last 30 days
node
24
Amazon
1
Resources
react-native-nitro-cookies — npm install react-native-nitro-cookies · libregistry