react-native-nitro-cookies
v1.3.1
Published
Fetch, Get Cookies 🍪 at the Speed of Nitro
Maintainers
Readme
Nitro Cookies
HTTP cookie management for React Native, built with Nitro Modules.
Documentation · 한국어 문서 · API reference · Releases
- Native cookie storage through Nitro Modules.
- Synchronous and asynchronous APIs.
- TypeScript types for cookie operations.
The documentation covers 1.3.0, including list queries, scoped deletion, and normalized errors. See the installation guide when upgrading from an earlier version.
Installation
Install both the library and its native runtime:
npm install react-native-nitro-cookies react-native-nitro-modules
# or
yarn add react-native-nitro-cookies react-native-nitro-modulesUse react-native-nitro-modules >=0.35.0 <1.0.0 and a React Native version compatible with that runtime.
For iOS, install pods from your app's ios/ directory:
bundle exec pod installIf your app does not use Bundler, run pod install instead.
Rebuild and launch the native app on either platform. Metro reload alone does not install a native module.
Expo apps require a development build containing both packages; Expo Go does not include this module.
Quick start
Set and read a cookie:
import NitroCookies from "react-native-nitro-cookies";
const url = "https://example.com/account";
await NitroCookies.set(url, {
name: "session",
value: "server-issued-token",
path: "/",
secure: true,
});
const cookies = await NitroCookies.get(url);On Android, set() submits the write without waiting for CookieManager's acknowledgment.
An immediate get() can return no cookie even after await set().
Confirm that the write is visible before using it for authentication.
Before you use cookies
- HttpOnly: This flag restricts browser
document.cookieaccess. It does not hide cookie values returned by this native API from React Native JavaScript. - iOS: Sync methods use shared storage. Async methods that accept
useWebKitcan select the default WebKit store; custom or ephemeral WebView stores cannot be selected. Read and write from the same store; cookies do not copy automatically. - tvOS: Cookie store operations use shared storage. Selecting WebKit with
useWebKit: truefails withWEBKIT_UNAVAILABLE. - Android: Cookie storage requires an installed, enabled WebView provider, even without a visible WebView. This also applies to Android TV.
- Global deletion:
clearAll()clears the entire selected store, including other domains. Review its scope before using it for logout or cleanup.
See platform support for the full API availability table and deployment requirements.
Guides and reference
- Your first cookie
- Stores and scope
- WebView integration
- Request headers
- Scoped deletion
- Migration from @react-native-cookies/cookies
- Normalized errors
- AI documentation: llms.txt · llms-full.txt
Contributing and example app
See CONTRIBUTING for workspace setup and validation. The example app uses the local package source for native checks. Published changes are listed in GitHub Releases.
Prior Art
This package is a from-scratch Nitro Modules implementation, not a fork, but its public API and behavior are modeled on @react-native-cookies/cookies. Big thanks to its maintainers and contributors for the original implementation and long-term work on the project.
Acknowledgement
License
Credits
Built with Nitro Modules by Marc Rousavy
