Skip to content
1.3.0 documentation · List APIs, scoped deletion, and normalized errors are available from 1.3.0. View release history ↗

Errors ​

Since 1.3.0. All 23 public operation failures throw or reject with an Error carrying a string code. Use the exported runtime enum to handle known cases.

ts
import NitroCookies, { CookieErrorCode } from "react-native-nitro-cookies";

try {
  await NitroCookies.get("https://example.com");
} catch (error) {
  if (error instanceof Error && "code" in error) {
    if (error.code === CookieErrorCode.WEBVIEW_UNAVAILABLE) {
      // Show an unavailable-cookie-store state.
    }
  }
}

Codes and recovery ​

CodeMeaningNext action
INVALID_URLMissing protocol or invalid URL.Supply a complete HTTP(S) URL.
DOMAIN_MISMATCHCookie or selector domain is incompatible with the URL.Check the host and original cookie scope.
PLATFORM_UNSUPPORTEDOperation is unavailable on this platform.Check the support table; avoid unsupported calls.
WEBKIT_UNAVAILABLERequested WebKit store cannot be used, including tvOS.Select shared storage where appropriate.
WEBVIEW_UNAVAILABLEAndroid's WebView-backed store cannot be initialized.Check provider availability; present a recoverable unavailable state.
PARSE_ERRORHeader parsing or selector validation failed.Check the input and required fields.
NETWORK_ERRORResponse fetching failed or had an unclassified failure.Check the destination and connectivity.
STORAGE_ERRORStorage failed or another operation had an unclassified failure.Inspect the original cause and store state.

Provider detection does not install WebView or create a fallback store.

Preserved details ​

The wrapper creates a new Error and preserves the original message, available stack, and thrown value through cause. It attaches the supplied url and, for single-cookie set and clear operations, cookieName. It does not add cookie values to context. Original messages and URLs can still contain application data.

Existing nonempty string codes are preserved, including unknown codes. Unclassified getFromResponse and getFromResponseList failures use NETWORK_ERROR; other operations use STORAGE_ERROR. Known bridge parsing follows Nitro 0.35.9 message formats and may need updates if the bridge changes.

Initialization failures ​

Import-time hybrid-object creation occurs outside operation normalization. If the native module cannot be found, check the native installation and rebuild the app before debugging cookie operations.

MIT licensed · React Native Nitro Cookies